paint-brush
Generate beautiful Swagger API documentation from Insomniaby@mlabouardy
24,417 reads
24,417 reads

Generate beautiful Swagger API documentation from Insomnia

by Mohamed LabouardyNovember 3rd, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

I recently built a tool called <a href="https://github.com/mlabouardy/swaggymnia" target="_blank"><strong>Swaggymnia</strong></a> to generate <a href="https://swagger.io/" target="_blank">Swagger</a> documentation for an existing API in <a href="https://insomnia.rest/" target="_blank">Insomnia </a>REST client. So brace yourself for a short but interesting quick tip read.
featured image - Generate beautiful Swagger API documentation from Insomnia
Mohamed Labouardy HackerNoon profile picture

I recently built a tool called Swaggymnia to generate Swagger documentation for an existing API in Insomnia REST client. So brace yourself for a short but interesting quick tip read.

Start by downloading Swaggymnia, find the appropriate package for your system and download it. For linux:

wget https://s3.amazonaws.com/swaggymnia/1.0.0-beta/linux/swaggymnia

After downloading Swaggymnia. Add the execution permission to the binary:

chmod +x swaggymnia

Note: For Windows make sure that swaggymnia binary is available on the PATH. This page contains instructions for setting the PATH on Windows.

After installing, verify the installation worked, by opening a new terminal session and checking if swaggymnia is available :

Once done, export your API from Insomnia:

Next, create a configuration file with the format below:

Then, issue the following command:

swaggymnia generate -i watchnow.json -c config.json -o yaml

As result, you should see a new file called swagger.yml generated:

Now our Swagger spec is generated, you can publish your Swagger spec as customer-facing documentation.

For this purpose you can use Swagger UI, which converts your Swagger spec into a beautiful, interactive API documentation.

You can download Swagger UI from here. It is just a bundle of HTML, CSS and JS files, which doesn’t require a framework or anything, so they can be installed in a directory on any HTTP server.

Once you have downloaded it, you put your swagger.yaml file into the dist directory — and open index.html and change it to point at your swagger file instead of http://petstore.swagger.io/v2/swagger.json.

Then you can open index.html in your browser, and see your new beautiful, interactive API documentation: