<?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: rahman orewole</title>
    <description>The latest articles on DEV Community by rahman orewole (@rahman_orewole_0d9b55e2a1).</description>
    <link>https://dev.to/rahman_orewole_0d9b55e2a1</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2986214%2F45351c69-f478-42fc-bd8d-bef431709440.png</url>
      <title>DEV Community: rahman orewole</title>
      <link>https://dev.to/rahman_orewole_0d9b55e2a1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rahman_orewole_0d9b55e2a1"/>
    <language>en</language>
    <item>
      <title>Effortless API Documentation with Maira-CLI: Generate Swagger Docs on the Fly</title>
      <dc:creator>rahman orewole</dc:creator>
      <pubDate>Fri, 28 Mar 2025 15:27:26 +0000</pubDate>
      <link>https://dev.to/rahman_orewole_0d9b55e2a1/effortless-api-documentation-with-maira-cli-generate-swagger-docs-on-the-fly-52c8</link>
      <guid>https://dev.to/rahman_orewole_0d9b55e2a1/effortless-api-documentation-with-maira-cli-generate-swagger-docs-on-the-fly-52c8</guid>
      <description>&lt;p&gt;Documenting APIs is often tedious, but what if you could generate detailed Swagger documentation automatically while testing your API? That's exactly what Maira-CLI does. This developer tool intercepts requests and responses to create accurate API documentation without additional effort.&lt;br&gt;
Getting Started with Maira-CLI&lt;br&gt;
Step 1: Install Maira-CLI&lt;br&gt;
First, install Maira-CLI globally on your system using npm:&lt;br&gt;
npm install -g maira-cli&lt;br&gt;
Step 2: Start the Proxy&amp;nbsp;Server&lt;br&gt;
Run the proxy inside the backend project you want to document. Replace values as needed:&lt;br&gt;
&lt;code&gt;maira-cli http --port=3000 --project=userDoc --baseurl=http://localhost:3000&lt;/code&gt;&lt;br&gt;
--port=3000: The port your backend server is running on.&lt;br&gt;
--project=userDoc: The name of the documentation folder.&lt;br&gt;
--baseurl=&lt;a href="http://localhost:3000:" rel="noopener noreferrer"&gt;http://localhost:3000:&lt;/a&gt; The base URL of your API.&lt;/p&gt;

&lt;p&gt;Step 3: Configure Routes and Authentication&lt;br&gt;
After running the command, Maira-CLI creates a folder: /maira_docs/userDoc/. Inside, you'll find:&lt;br&gt;
config.json: Define project details, routes to document, and authentication headers.&lt;br&gt;
paths.json: Stores detected API paths and request details.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Example config.json&lt;br&gt;
{&lt;br&gt;
  "title": "User Documentation",&lt;br&gt;
  "version": "1.0.0",&lt;br&gt;
  "serverUrls": ["http://localhost:3000"],&lt;br&gt;
  "routes": [&lt;br&gt;
    "/ping/pong",&lt;br&gt;
    "/ping",&lt;br&gt;
    "/ping/:id"&lt;br&gt;
  ],&lt;br&gt;
  "security": {&lt;br&gt;
    "apiKey": ["x-api-key", "x-api-user"],&lt;br&gt;
    "http": ["authorization"]&lt;br&gt;
  }&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
Once configured, make API requests through the proxy (&lt;a href="http://localhost:8081" rel="noopener noreferrer"&gt;http://localhost:8081&lt;/a&gt;) just as you would normally.&lt;br&gt;
Step 4: Generating Documentation&lt;br&gt;
Maira-CLI generates a swagger_template.json file based on config.json. After making requests, run:&lt;br&gt;
&lt;code&gt;maira-cli generate -c=./maira_docs/userDoc/swagger_template.json -p=./maira_docs/userDoc/paths.json -o=./maira_docs/userDoc/docs -n=user-docs.json&lt;/code&gt;&lt;br&gt;
Step 5: Viewing Your Documentation&lt;br&gt;
Once generation is complete, you'll receive a preview link, like:&lt;br&gt;
&lt;code&gt;https://maira-virid.vercel.app/?id=uuid&lt;/code&gt;&lt;br&gt;
This link allows you to share and view your API documentation effortlessly.&lt;br&gt;
Why Use Maira-CLI?&lt;br&gt;
✅ No manual Swagger setup - Everything is automatically generated while you test your API. ✅ Captures request &amp;amp; response data - Ensures accurate documentation. ✅ Supports authentication headers - Securely documents API access methods. ✅ Easy preview &amp;amp; sharing - Get a hosted link to your generated docs.&lt;br&gt;
Maira-CLI makes API documentation simple and efficient. Try it today! 🚀&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>swagger</category>
      <category>openapi</category>
    </item>
  </channel>
</rss>
