How to create OpenAPI swagger from postman collection using Postbot AI
In blog I will explain the steps to convert a postman collection to OpenAPI file using Postbot AI.
It could be a time taking task to write a OpenAPI spec file from scratch when you already have a postman collection. This blog will help u to shorten the time it takes to write a OpenAPI spec file from a postman collection which also uses postbot for describing your API.
Step 1.
First create a collection of all your API endpoints using postman. Add your API requests in postman and hit send for each API endpoint. Once it is doen for eacj request move to next step
.
Step 2.
Now we will create a documentation of all our APIs using postbot. Go to your API endpoint and at bottom click on Posbot and a chatbox will appear on your screen. Click on “Add Documentation” command which will automatically generate a documentation for the postman request. Please hit the endpoint once successfully before clickong on add docuemntation as it works only on API endpoint with a response.
Step 3.
After clicking on the Add documentation you can see in the documentation part of API endpoint on right side that that documentation was written by Postbot. Do this for all your endpoints in your collection.
Step 4.
Now you have to create a postman key using this link. Save the key value as this is only time you can see this. Keep the key securely.
Step 5.
Now fetch the ID of the Collection you wish to convert. This can be found by selecting the Collection in Postman, navigating to the right-hand sidebar, clicking the Info
tab (symbolized by the i
icon), and copying the ID
.
Step 6.
Fork this postman collection in your postman. https://www.postman.com/postman/postman-public-workspace/request/k9uuflp/generate-a-swagger-schema
Step 7.
After you have succefully forked the collection go to the variables section of forked postman collection and paste the collection id and postman api key in the variable values and hit Save button.
Step 8.
Go to get request of forked collection and replace the colleciton id in get rquest collection to {{collection_uid}}
and hit SEND button.
Step 9.
In the response of get request go to under visualize tab. Under the visualize tab copy the response of API and paste to https://editor.swagger.io/ website to see that you OpenAPI file is created successfully.
Last Step: Voila!
Your OpenAPI file is created successfully. You can now edit is as you want. Hopefully I have given u a fast way to automate the OpenAPI spec file creation from postman collection with full description.