When it comes to documenting Application Programming Interfaces (APIs), the most popular format is the OpenAPI Specification (OAS). It provides a standardized, easy-to-read, and machine-friendly way to describe APIs. This helps developers, testers, and technical writers understand and work with your API more easily.
This specification is often written in YAML, allowing automatic documentation generation, better API validation, and easy integration with tools like Mintlify and Swagger.
This guide will teach you how to convert your existing API doc into OpenAPI in less than five minutes.
The first step in this process is to export the API documentation. If you don't have your API documentation, use Postman to test and document the API. Make sure to add examples to each endpoint and organize them in folders for better readability and easy navigation.
After you've done that, follow these processes to export the doc:
At the top API folder, click on the three-dot (…)
Click on Export.
You will see a pop asking you for confirmation; click on “Export.”
This will automatically download the file to your PC as a JSON file.
The second is to convert the JSON file to OpenAPI using Kevin Swiber.
Go to Kevin Swiber
Open the API doc you previously downloaded from Postman, and copy the content.
Paste the content under the “Postman Collection JSON” field.
Copy the converted content under the “OpenAPI” field.
Your API documentation has been automatically converted to OpenAPI in just a few seconds. 🎉
After you've converted this file, you'll need to edit it. This is because some parameters need to be explicitly defined based on their data type, or you might want to add features that can't be included when documenting in Postman.
To do this:
You might encounter issues like:
Not all endpoints or folders are showing up
This can happen if you save your base URL as a variable when documenting your API in Postman. Go back to the file, and use the URL directly.
Swagger Editor is reloading or showing a 404 error while editing the file
If this happens, you might lose your file. To avoid this, after editing the OpenAPI for a while, copy the content and save it somewhere. You can do this every 3-5 minutes.
In this article, you've learned how to convert your API documentation to OpenAPI in just a few minutes using Kevin Swiber's OpenAPI converter. The guide also highlights potential issues you might encounter during this process and offers possible solutions to these problems.