I had to do some exploring/testing of an API today and thought that Postman would be the tool for the job.
The API had an OpenAPI endpoint built with Swagger where I could download a JSON specification file for the API.
And lucky me, I found this repository, openapi-to-postman. Now I could easily get a collection of requests for the API I wanted to explore. This without manually building up each request in Postman.
The tool is a Node module and converts OpenAPI specification files to a file format that can be imported by Postman.
This is how I used it in this case. First step is to install the tool.
npm i -g openapi-to-postmanv2
Then I navigated to my downloaded openapi.json
and used this command.
npx openapi2postmanv2 -s openapi.json -o collection.json -p -O folderStrategy=Tags,includeAuthInfoInExample=false
Which created the collection.json
file that I could use to import it in Postman.
Very easy and simple! The funny thing is that after this I found this documentation, Integrate Postman with OpenAPI, on learning.postman.com.
The import already support the OpenAPI standard, so I didn't really need to use the converter at all.
Sometimes it's best to start with the documentation than start searching on the net. However, the good part was that the converting step was super easy, and the collection worked perfectly with Postman.