Skip to content

Commit

Permalink
Publishing site Lun 11 mar 2024 18:23:03 CET
Browse files Browse the repository at this point in the history
  • Loading branch information
lbroudoux committed Mar 11, 2024
1 parent 45cb18f commit cf95a8f
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 9 deletions.
2 changes: 1 addition & 1 deletion documentation/using/index.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<description>Recent content in Using on API Mocking and Testing | Microcks.io</description>
<generator>Hugo -- gohugo.io</generator>
<language>en-US</language>
<lastBuildDate>Thu, 07 Mar 2024 00:00:00 +0100</lastBuildDate>
<lastBuildDate>Mon, 11 Mar 2024 00:00:00 +0100</lastBuildDate>
<atom:link href="https://microcks.io/documentation/using/index.xml" rel="self" type="application/rss+xml" />
<item>
<title>Importing Services &amp; APIs</title>
Expand Down
63 changes: 59 additions & 4 deletions documentation/using/openapi/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23441,8 +23441,8 @@
<h2 class="mb-4 fw-bold">OpenAPI Mocking and Testing</h2>


<span class="text-muted fw-300">🗓️ Last updated on February 23, 2022
<span class="mx-1 text-dark-50 fw-300">|</span> <i class="far fa-clock text-dark me-1"></i> 5
<span class="text-muted fw-300">🗓️ Last updated on March 11, 2024
<span class="mx-1 text-dark-50 fw-300">|</span> <i class="far fa-clock text-dark me-1"></i> 6
<span class="mx-1 text-dark-50 fw-300">|</span> <a href="https://github.com/microcks/microcks.io/edit/master/content/documentation/using/openapi.md" class="f6 ph3 pv1 br2 dib tc ttu mv3 bg-primary-color white hover-bg-green link">Improve this page</a>
</span>

Expand Down Expand Up @@ -23619,7 +23619,58 @@ <h4 id="query-parameters">Query parameters</h4>
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> {&#34;name&#34;: &#34;307&#34;, &#34;model&#34;: &#34;Peugeot 307&#34;, &#34;year&#34;: 2003},
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> {&#34;name&#34;: &#34;jean-pierre&#34;, &#34;model&#34;: &#34;Peugeot Traveller&#34;, &#34;year&#34;: 2017}
</span></span></span><span style="display:flex;"><span><span style="color:#e6db74"> ]</span>
</span></span></code></pre></div><p>And yes&hellip; I&rsquo;ve called one of my car jean-pierre&hellip; ;-)</p>
</span></span></code></pre></div><p>And yes&hellip; I&rsquo;ve called one of my car jean-pierre&hellip; 😉</p>
<h4 id="no-content-response-payload">No content response payload</h4>
<p>Now let&rsquo;s imagine the case where ou&rsquo;re dealing with an API operation that returns &ldquo;No Content&rdquo;. This could by - for example - an operation that takes care of deleting a car from the database and return a simple <code>204</code> HTTP response code once done.</p>
<p>In that case, we cannot rely on <a href="https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#exampleObject"




target="_blank"



>Example Objects</a>
because the response has typically no content we can attach an <code>example</code> to. We need another way to specify the matching of this response with an incoming request. For this, we introduced a specific <code>x-microcks-refs</code> extension that allows to tell Microcks on which requests it should match this response.</p>
<p>Let&rsquo;s illustrate the above-mentioned case with this snippet below:</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-yaml" data-lang="yaml"><span style="display:flex;"><span><span style="color:#ae81ff">/owner/{owner}/car/{car}:</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">delete</span>:
</span></span><span style="display:flex;"><span> <span style="color:#f92672">parameters</span>:
</span></span><span style="display:flex;"><span> - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">owner</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">in</span>: <span style="color:#ae81ff">path</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">description</span>: <span style="color:#ae81ff">Owner of the cars</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">required</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">schema</span>:
</span></span><span style="display:flex;"><span> <span style="color:#f92672">format</span>: <span style="color:#ae81ff">string</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">type</span>: <span style="color:#ae81ff">string</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">examples</span>:
</span></span><span style="display:flex;"><span> <span style="color:#f92672">laurent_307</span>:
</span></span><span style="display:flex;"><span> <span style="color:#f92672">value</span>: <span style="color:#ae81ff">laurent</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">laurent_jp</span>:
</span></span><span style="display:flex;"><span> <span style="color:#f92672">value</span>: <span style="color:#ae81ff">laurent</span>
</span></span><span style="display:flex;"><span> - <span style="color:#f92672">name</span>: <span style="color:#ae81ff">car</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">in</span>: <span style="color:#ae81ff">path</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">description</span>: <span style="color:#ae81ff">Owner of the cars</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">required</span>: <span style="color:#66d9ef">true</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">schema</span>:
</span></span><span style="display:flex;"><span> <span style="color:#f92672">format</span>: <span style="color:#ae81ff">string</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">type</span>: <span style="color:#ae81ff">string</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">examples</span>:
</span></span><span style="display:flex;"><span> <span style="color:#f92672">laurent_307</span>:
</span></span><span style="display:flex;"><span> <span style="color:#f92672">value</span>: <span style="color:#e6db74">&#39;307&#39;</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">laurent_jp</span>:
</span></span><span style="display:flex;"><span> <span style="color:#f92672">value</span>: <span style="color:#e6db74">&#39;jean-pierre&#39;</span>
</span></span><span style="display:flex;"><span><span style="color:#f92672">responses</span>:
</span></span><span style="display:flex;"><span> <span style="color:#f92672">204</span>:
</span></span><span style="display:flex;"><span> <span style="color:#f92672">description</span>: <span style="color:#66d9ef">No</span> <span style="color:#ae81ff">Content</span>
</span></span><span style="display:flex;"><span> <span style="color:#f92672">x-microcks-refs</span>:
</span></span><span style="display:flex;"><span> - <span style="color:#ae81ff">laurent_307</span>
</span></span><span style="display:flex;"><span> - <span style="color:#ae81ff">laurent_jp</span>
</span></span></code></pre></div><p>When Microcks will receive <code>DELETE /owner/laurent/car/307</code> or <code>DELETE /owner/laurent/car/jean-pierre</code> call, it will just reply using a <code>204</code> HTTP response code.</p>
<blockquote>
<p>Note that this association also works if you defined some <code>requestBody</code> examples for the operation.</p>
</blockquote>
<h2 id="importing-openapi-specification">Importing OpenAPI specification</h2>
<p>When you&rsquo;re happy with your API design and example definitions just put the result YAML or JSON file into your favorite Source Configuration Management tool, grab the URL of the file corresponding to the branch you want to use and add it as a regular Job import into Microcks. On import, Microcks should detect that it&rsquo;s an OpenAPI specification file and choose the correct importer.</p>
<p>Using the above <code>Car API</code> example, you should get the following results:</p>
Expand Down Expand Up @@ -23818,7 +23869,11 @@ <h2 id="using-openapi-extensions">Using OpenAPI extensions</h2>
</ol>
</li>
<li><a href="#specifying-request-payload">Specifying request payload</a></li>
<li><a href="#specifying-response-payload">Specifying response payload</a></li>
<li><a href="#specifying-response-payload">Specifying response payload</a>
<ol>
<li><a href="#no-content-response-payload">No content response payload</a></li>
</ol>
</li>
</ol>
</li>
<li><a href="#importing-openapi-specification">Importing OpenAPI specification</a></li>
Expand Down
Loading

0 comments on commit cf95a8f

Please sign in to comment.