Skip to content

Commit 8f607a4

Browse files
committed
Publishing site Fri Nov 21 09:38:09 CET 2025
1 parent 140a3f4 commit 8f607a4

7 files changed

Lines changed: 7 additions & 7 deletions

File tree

documentation/guides/usage/importing-content/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
<i class="fas fa-chevron-down toggle-icon"></i></a><li data-nav-id=https://microcks.io/documentation/references/apis/ title="API Reference" class=sidelist-mobile><a href=https://microcks.io/documentation/references/apis/ class="d-flex align-items-center justify-content-between"><span><i class="fa-solid fa-caret-right"></i> &nbsp; API Reference</span>
4646
<i class="fas fa-chevron-down toggle-icon"></i></a></ul></li></ul></div></div></div></div><div class="col-xl-8 col-lg-9 col-md-8"><div class="px-lg-5 px-sm-4 py-5"><h2 class="mb-4 fw-bold">Importing Services & APIs</h2><span class="text-muted fw-300">🗓️ Last updated on June 7, 2024
4747
<span class="mx-1 text-dark-50 fw-300">|</span> <i class="far fa-clock text-dark me-1"></i> 6
48-
<span class="mx-1 text-dark-50 fw-300">|</span> <a href=https://github.com/microcks/microcks.io/edit/master/content/documentation/guides/usage/importing-content.md class="f6 ph3 pv1 br2 dib tc ttu mv3 bg-primary-color white hover-bg-green link">Improve this page</a></span><div class="doc-content mt-4 pt-4" data-bs-spy=scroll data-bs-target=#TableOfContents data-bs-offset=20><h2 id=overview>Overview</h2><p>This guide will show you and discuss the different options for importing Services and APIs into Microcks. There are basically two different ways of putting new content into Microcks:</p><ol><li>Pushing content to Microcks via Upload,</li><li>Having Microcks pulling content via Importer.</li></ol><p>We will consider the pros and cons of the different methods.</p><h2 id=1-import-content-via-upload>1. Import content via Upload</h2><h3 id=via-the-ui>Via the UI</h3><p>The simplest way of adding new Services or API mocks to your Microcks instance is by directly uploading the artifact. From the left vertical navigation bar, just select the <strong>Importers</strong> menu entry and then choose <code>Upload</code>. You&rsquo;ll then see a dialog window allowing you to browse your filesystem and pick a new file to upload.</p><div align=center><figure><img src=/images/documentation/artifacts-upload.png width=80%></figure></div><blockquote><p>💡 You can also specify whether this artifact should be considered as <code>primary</code> or <code>secondary</code> per the <a href=/documentation/explanations/multi-artifacts>Multi Artifacts support</a>. In the case of a <code>secondary</code> artifact, you may check the <em>Just merge examples into existing API | Service definition</em> box.</p></blockquote><p>Hit the <code>Upload</code> green button. An upload followed by an artifact import should occur, with notification messages appearing at the top right corner. Newly discovered Services and APIs can be found in the <strong>APIs | Services</strong> repository.</p><p>While this method is very convenient for a quick test, you&rsquo;ll have to re-import your artifact file on every new change&mldr;</p><h3 id=via-the-api>Via the API</h3><p>The same thing can be done via Microcks&rsquo; own API. Be sure to start reading the <a href=/documentation/guides/automation/api>Connecting to Microcks API</a> guide first, and to retrieve a <code>token</code> by running the authentication flow. The <em>Service Account</em> you use for this operation is required to have the <code>manager</code> role, which is not the case with the default one, as explained in <a href=/documentation/explanations/service-account/#inspecting-default-service-account>Inspecting default Service Account</a>.</p><p>Once you have the <code>$TOKEN</code> issued for the correct account, uploading a new Artifact is just a matter of executing this <code>curl</code> command:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-sh data-lang=sh><span style=display:flex><span><span style=color:#75715e># Uploading a local artifact.</span>
48+
<span class="mx-1 text-dark-50 fw-300">|</span> <a href=https://github.com/microcks/microcks.io/edit/master/content/documentation/guides/usage/importing-content.md class="f6 ph3 pv1 br2 dib tc ttu mv3 bg-primary-color white hover-bg-green link">Improve this page</a></span><div class="doc-content mt-4 pt-4" data-bs-spy=scroll data-bs-target=#TableOfContents data-bs-offset=20><h2 id=overview>Overview</h2><p>This guide will show you and discuss the different options for importing Services and APIs into Microcks. There are basically two different ways of putting new content into Microcks:</p><ol><li>Pushing content to Microcks via Upload,</li><li>Having Microcks pulling content via Importer.</li></ol><p>We will consider the pros and cons of the different methods.</p><h2 id=1-import-content-via-upload>1. Import content via Upload</h2><h3 id=via-the-ui>Via the UI</h3><p>The simplest and fastest way to add new Services or API mocks is to use the UI Quick Import. Click the <strong>Quick Import</strong> button in the top-right corner of the screen, or simply drag-and-drop a file anywhere on the UI — either action will start the upload and import flow. A dialog will appear where you can adjust options and confirm the upload.</p><div align=center><figure><img src=/images/documentation/artifacts-upload.png width=80%></figure></div><blockquote><p>💡 You can also specify whether this artifact should be considered as <code>primary</code> or <code>secondary</code> per the <a href=/documentation/explanations/multi-artifacts>Multi Artifacts support</a>. In the case of a <code>secondary</code> artifact, you may check the <em>Secondary Artifact</em> box.</p></blockquote><p>After choosing your artifacts, click the green <code>Upload</code> button to send them to Microcks. Notification messages will appear in the top-right corner to inform you of the process. Newly discovered Services and APIs can be found in the <strong>APIs | Services</strong> repository.</p><p>While this method is very convenient for a quick test, you&rsquo;ll have to re-import your artifact file on every new change. To watch the changes of local files you can check out the <a href=https://github.com/microcks/microcks-cli/blob/master/documentation/cmd/import.md target=_blank>Microcks CLI Import</a></p><h3 id=via-the-api>Via the API</h3><p>The same thing can be done via Microcks&rsquo; own API. Be sure to start reading the <a href=/documentation/guides/automation/api>Connecting to Microcks API</a> guide first, and to retrieve a <code>token</code> by running the authentication flow. The <em>Service Account</em> you use for this operation is required to have the <code>manager</code> role, which is not the case with the default one, as explained in <a href=/documentation/explanations/service-account/#inspecting-default-service-account>Inspecting default Service Account</a>.</p><p>Once you have the <code>$TOKEN</code> issued for the correct account, uploading a new Artifact is just a matter of executing this <code>curl</code> command:</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-sh data-lang=sh><span style=display:flex><span><span style=color:#75715e># Uploading a local artifact.</span>
4949
</span></span><span style=display:flex><span>curl <span style=color:#e6db74>&#39;https://microcks.example.com/api/artifact/upload?mainArtifact=true&#39;</span> -H <span style=color:#e6db74>&#34;Authorization: Bearer </span>$TOKEN<span style=color:#e6db74>&#34;</span> -F <span style=color:#e6db74>&#39;file=@samples/films.graphql&#39;</span> -k
5050
</span></span></code></pre></div><h3 id=configure-dependency-resolution>Configure dependency resolution</h3><p>Direct upload is straightforward and quick to realize, but comes with one caveat: it does not allow you to automatically resolve dependencies. For example, if your artifact file uses external references with relative paths, Microcks is not able to resolve these external references by default.</p><p>As a workaround to this limitation, and since Microcks <code>1.10.1</code>, we introduced a new <code>default-artifacts-repository.url</code> property that takes the value of <code>DEFAULT_ARTIFACTS_REPOSITORY_URL</code> environment variable when defined. It can be set to either an HTTP endpoint (starting with <code>http[s]://</code>) or a file endpoint (starting with <code>file://</code>). This default repository for artifacts will be used as the default location for Microcks to resolve relative dependencies.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-properties data-lang=properties><span style=display:flex><span><span style=color:#a6e22e>default-artifacts-repository.url</span><span style=color:#f92672>=</span><span style=color:#e6db74>${DEFAULT_ARTIFACTS_REPOSITORY_URL:#{null}}</span>
5151
</span></span></code></pre></div><blockquote><p>💡 For local development purposes, this is super convenient to use a very small HTTP server running on your laptop or a common folder mounted into Microcks container as the default artifacts repository.</p></blockquote><h2 id=2-import-content-via-importer>2. Import content via Importer</h2><p>Another way of adding new Services or APIs mocks is by scheduling an <strong>Importer Job</strong> into Microcks. We think it&rsquo;s actually the best way to achieve continuous, iterative and incremental discovery of your Services and APIs. The principle is very simple: you save your artifact file into the Git repository of your choice (public or private), and Microcks will take care of periodically checking if changes have been applied and new mock or service definitions are present in your artifact. The nice thing about using Importer is that external files referenced in the target artifact will be automatically resolved for you.</p><div align=center><figure><img src=/images/documentation/artifacts-scheduling.png width=80%></figure></div><blockquote><p>💡 Though we think that Git repositories (or other version control systems) are the best place to keep such artifacts, Microcks only requires a simple HTTP service. So you may store your artifact on a simple filesystem as long as it is reachable using HTTP.</p></blockquote><p>Still from the left vertical navigation bar, just select the <strong>Importers</strong> menu entry to see the list of existing importers.</p><h3 id=creating-a-new-scheduled-import>Creating a new scheduled import</h3><p>You may declare a new Importer job by hitting the <code>Create</code> button.</p><p>A wizard modal then appears, as creating an Importer is a three-step process. The first step concerns mandatory basic properties such as the name of your Importer and the repository URL it will use to check for discovering API mocks.</p><div align=center><figure><img src=/images/importer-step1.png width=90%></figure></div><blockquote><p>💡 You can also specify whether this artifact should be considered as <code>primary</code> or <code>secondary</code> per the <a href=/documentation/explanations/multi-artifacts>Multi Artifacts support</a>. In the case of a <code>secondary</code> artifact, you may check the <em>Just merge examples into existing API | Service definition</em> box.</p></blockquote><p>The second step concerns authentication options for accessing the repository. Depending on the type of repository (public or private), you may need to enable/disable certificate validation and manage an authentication process through the usage of a <strong>Secret</strong>. For more info, check the guide on <a href=/documentation/guides/administration/secrets>External Secrets</a>.</p><div align=center><figure><img src=/images/importer-step2.png width=90%></figure></div><p>Finally, the review displays a summary before creating the Importer Job.</p><div align=center><figure><img src=/images/importer-step3.png width=90%></figure></div><h3 id=managing-scheduled-importers>Managing scheduled importers</h3><p>At creation time, the importer job is automatically <code>Scanned</code> and <code>Imported</code>.</p><p>Once created, importer jobs can be managed, activated or forced through this screen. You&rsquo;ll see a colored marker for each job line:</p><ul><li><code>Scanned</code> means that the job is actually scheduled for the next importation run. Otherwise, <code>Inactive</code> will be displayed.</li><li><code>Imported</code> means that the job has been successfully imported on a previous run. Otherwise, <code>Last import errors</code> will be displayed with a popup showing the last error,</li><li><code>Services</code> is a shortcut to access the services definitions discovered by this job.</li></ul><p>Using the 3-dotted menu, you can easily enable/disable or force the job.</p><div align=center><figure><img src=/images/importer-status.png width=90%></figure></div><h3 id=configure-scheduling-interval>Configure scheduling interval</h3><p>The scheduling interval can be globally configured for all Jobs. It is a global setting and not a per-job one. This is achieved through the <code>services.update.interval</code> property in the <code>application.properties</code> configuration file, which takes the value of the <code>SERVICES_UPDATE_INTERVAL</code> environment variable. The value should be set to a valid <a href=https://spring.io/blog/2020/11/10/new-in-spring-5-3-improved-cron-expressions target=_blank>CRON expression</a>; the default is every 2 hours.</p><div class=highlight><pre tabindex=0 style=color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4><code class=language-properties data-lang=properties><span style=display:flex><span><span style=color:#a6e22e>services.update.interval</span><span style=color:#f92672>=</span><span style=color:#e6db74>${SERVICES_UPDATE_INTERVAL:0 0 0/2 * * *}</span>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>API Reference on API Mocking and Testing | Microcks.io</title><link>https://microcks.io/documentation/references/apis/</link><description>Recent content in API Reference on API Mocking and Testing | Microcks.io</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Mon, 24 Feb 2025 00:00:00 +0100</lastBuildDate><atom:link href="https://microcks.io/documentation/references/apis/index.xml" rel="self" type="application/rss+xml"/><item><title>Microcks' OpenAPI</title><link>https://microcks.io/documentation/references/apis/open-api/</link><pubDate>Mon, 11 Nov 2019 00:00:00 +0100</pubDate><guid>https://microcks.io/documentation/references/apis/open-api/</guid><description>As a tool focused on APIs, Microcks also offers its own API that allows you to query its datastore and control the import jobs and configuration objects.</description></item><item><title>Microcks' AsyncAPI</title><link>https://microcks.io/documentation/references/apis/async-api/</link><pubDate>Mon, 29 Apr 2024 00:00:00 +0200</pubDate><guid>https://microcks.io/documentation/references/apis/async-api/</guid><description>As a tool focused on APIs and Events, Microcks also offers its own Events API that allows you subscribe to events produced by Microcks.</description></item></channel></rss>
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>API Reference on API Mocking and Testing | Microcks.io</title><link>https://microcks.io/documentation/references/apis/</link><description>Recent content in API Reference on API Mocking and Testing | Microcks.io</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Fri, 24 Oct 2025 00:00:00 +0200</lastBuildDate><atom:link href="https://microcks.io/documentation/references/apis/index.xml" rel="self" type="application/rss+xml"/><item><title>Microcks' OpenAPI</title><link>https://microcks.io/documentation/references/apis/open-api/</link><pubDate>Mon, 11 Nov 2019 00:00:00 +0100</pubDate><guid>https://microcks.io/documentation/references/apis/open-api/</guid><description>As a tool focused on APIs, Microcks also offers its own API that allows you to query its datastore and control the import jobs and configuration objects.</description></item><item><title>Microcks' AsyncAPI</title><link>https://microcks.io/documentation/references/apis/async-api/</link><pubDate>Mon, 29 Apr 2024 00:00:00 +0200</pubDate><guid>https://microcks.io/documentation/references/apis/async-api/</guid><description>As a tool focused on APIs and Events, Microcks also offers its own Events API that allows you subscribe to events produced by Microcks.</description></item></channel></rss>

0 commit comments

Comments
 (0)