<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Supervinh</title>
    <description>The latest articles on DEV Community by Supervinh (@supervinh).</description>
    <link>https://dev.to/supervinh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2207764%2F088d2c1a-2299-4d2b-9cb2-738c1e67d93c.png</url>
      <title>DEV Community: Supervinh</title>
      <link>https://dev.to/supervinh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/supervinh"/>
    <language>en</language>
    <item>
      <title>Microcks for dummies</title>
      <dc:creator>Supervinh</dc:creator>
      <pubDate>Thu, 09 Jan 2025 00:19:39 +0000</pubDate>
      <link>https://dev.to/optnc/microcks-for-dummies-1imn</link>
      <guid>https://dev.to/optnc/microcks-for-dummies-1imn</guid>
      <description>&lt;h2&gt;
  
  
  🤔 Microcks: For Whom and For What?
&lt;/h2&gt;

&lt;p&gt;How can you tell if API documentation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Is properly documented ?&lt;/li&gt;
&lt;li&gt;Is sufficient for effective usage ?&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Allows partners/clients&lt;/strong&gt; to efficiently test ?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is exactly what &lt;a href="https://microcks.io/" rel="noopener noreferrer"&gt;Microcks&lt;/a&gt;, an open-source tool, promises to deliver. Its benefits have already been explored in one of &lt;a href="https://dev.to/adriens/series/18414"&gt;OPT-NC’s public APIs for agency waiting times&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1862247586411028971-410" src="https://platform.twitter.com/embed/Tweet.html?id=1862247586411028971"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1862247586411028971-410');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1862247586411028971&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;h2&gt;
  
  
  🤓 Spoilers
&lt;/h2&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/K0lFZwJlHp8"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  📜 Annotations and REST API Documentation Quality
&lt;/h2&gt;

&lt;p&gt;Why document a REST API using annotations directly in the source code?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;💡 &lt;strong&gt;Clarity for developers&lt;/strong&gt;: Annotations precisely describe endpoints, parameters, and responses, making the API easier to understand.&lt;/li&gt;
&lt;li&gt;🔄 &lt;strong&gt;Automatic updates&lt;/strong&gt;: Generating OpenAPI documentation from annotations ensures that it stays aligned with the source code in a simple and efficient way.&lt;/li&gt;
&lt;li&gt;📚 &lt;strong&gt;Concrete examples&lt;/strong&gt;: Annotations also allow adding example calls, helping developers understand practical use cases.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s an example of annotations:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@GET&lt;/span&gt;
&lt;span class="nd"&gt;@Path&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/endpoint"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@Operation&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;summary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Operation summary"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Detailed description"&lt;/span&gt;
&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@APIResponses&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                &lt;span class="nd"&gt;@APIResponse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
                        &lt;span class="n"&gt;responseCode&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"200"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                        &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"OK response"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                        &lt;span class="n"&gt;content&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nd"&gt;@Content&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
                                &lt;span class="n"&gt;mediaType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"application/json"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                                &lt;span class="n"&gt;schema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nd"&gt;@Schema&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;implementation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
                                &lt;span class="n"&gt;examples&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                                        &lt;span class="nd"&gt;@ExampleObject&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
                                                &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Example 1"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                                                &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"{'key':'value'}"&lt;/span&gt;
                                        &lt;span class="o"&gt;)&lt;/span&gt;
                                &lt;span class="o"&gt;}&lt;/span&gt;
                        &lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;)&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;ReturnValue&lt;/span&gt; &lt;span class="nf"&gt;myFunction&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And to describe &lt;strong&gt;request parameters&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@GET&lt;/span&gt;
&lt;span class="nd"&gt;@Path&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/endpoint/{id}"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;ReturnValue&lt;/span&gt; &lt;span class="nf"&gt;myFunction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="nd"&gt;@Parameter&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
                &lt;span class="n"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Expected ID"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
                &lt;span class="n"&gt;schema&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nd"&gt;@Schema&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"integer"&lt;/span&gt;&lt;span class="o"&gt;),&lt;/span&gt;
                &lt;span class="n"&gt;examples&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                        &lt;span class="nd"&gt;@ExampleObject&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"Example ID"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"123"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;})&lt;/span&gt;
        &lt;span class="nd"&gt;@PathParam&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"id"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;
&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Validation and Security with Swagger:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Validation&lt;/strong&gt; of parameters and responses.&lt;/li&gt;
&lt;li&gt;🔒 &lt;strong&gt;Endpoint security&lt;/strong&gt; to prevent injection attacks.&lt;/li&gt;
&lt;li&gt;🚫 &lt;strong&gt;Rejection&lt;/strong&gt; of invalid values (e.g., negative numbers for non-allowed parameters).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;But documentation - and hence its quality - must also be tested!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;💼 &lt;strong&gt;Enter Microcks&lt;/strong&gt;: This open-source tool generates mocks from OpenAPI annotations, enabling:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🌐 &lt;strong&gt;API testing&lt;/strong&gt; without actual deployment.&lt;/li&gt;
&lt;li&gt;🧪 &lt;strong&gt;Evaluation&lt;/strong&gt; of documentation quality and completeness.&lt;/li&gt;
&lt;li&gt;📊 &lt;strong&gt;Scoring&lt;/strong&gt; for OpenAPI compliance to ensure high standards.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With Microcks, documenting is not just writing, it ensures everything works as expected, leading to robust, well-documented APIs. -&amp;gt; ...that can be embedded as part of a CI&lt;/p&gt;

&lt;h2&gt;
  
  
  🚀 Microcks: Boosting Developer Experience
&lt;/h2&gt;

&lt;p&gt;Thanks to annotations and the mocks generated by Microcks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;📝 &lt;strong&gt;Clarity even before development&lt;/strong&gt;: API functionalities are defined upfront, making communication between developers, test managers, project managers and future users easier.&lt;/li&gt;
&lt;li&gt;⏱️ &lt;strong&gt;Time-saving&lt;/strong&gt;: Development and documentation can progress in parallel, optimizing project resources, allowing those depending on the API to start development even before the API itself is implemented.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Microcks transforms how APIs are designed, tested, and shared, creating a seamless and efficient DEVEX (developer experience).&lt;/p&gt;

&lt;h3&gt;
  
  
  🔍 Microcks and the Testing Pyramid
&lt;/h3&gt;

&lt;p&gt;Among the various representations of testing strategies, &lt;strong&gt;Watirmelon’s&lt;/strong&gt; model stands out as particularly insightful.&lt;/p&gt;

&lt;p&gt;🧩 Microcks fits into the &lt;strong&gt;Automated API Tests&lt;/strong&gt; layer, with a particular focus on &lt;a href="https://pactflow.io/blog/what-is-contract-testing/" rel="noopener noreferrer"&gt;Contract Testing&lt;/a&gt;, ensuring that APIs adhere to their specifications.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://microcks.io/documentation/explanations/conformance-testing/" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fpbngx28wzftbpkwcv0hs.png" alt="Ideal Software Testing Pyramide" width="800" height="573"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🎯 Personal and team benefits
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;✅ &lt;strong&gt;Documentation quality&lt;/strong&gt;: I was pleasantly surprised by the clarity and precision of the documentation provided by Microcks.&lt;/li&gt;
&lt;li&gt;🎨 &lt;strong&gt;Intuitive user interface&lt;/strong&gt;: The UI is simple, intuitive, and very enjoyable to use, making the tool accessible right from the start.&lt;/li&gt;
&lt;li&gt;⚡ &lt;strong&gt;Developer responsiveness&lt;/strong&gt;: The contributors of Microcks are highly active on GitHub and respond quickly to issues, which is reassuring when resolving potential roadblocks.&lt;/li&gt;
&lt;li&gt;🚀 &lt;strong&gt;Unblocking my tests&lt;/strong&gt;: In my last project, I struggled to mock calls to OpenSearch. With Microcks, I no longer need to mock the calls. I can simply simulate the database to contact, which saves time and greatly simplifies testing.&lt;/li&gt;
&lt;li&gt;🔮 &lt;strong&gt;Usefulness for future projects&lt;/strong&gt;: Microcks will be invaluable for my future projects, especially during the development phases. Instead of relying on paid APIs, I can simply use my Microcks mock, which is both more economical and practical.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Microcks has proven to be a powerful ally, not only for this project but also for those to come.&lt;/p&gt;

</description>
      <category>api</category>
      <category>testing</category>
      <category>productivity</category>
      <category>opensource</category>
    </item>
  </channel>
</rss>
