Convert Postman Collection to OpenAPI Yaml

If you have never converted Postman Collection to OpenAPI Yaml before it can be a bit daunting task. Just follow the below simple steps to convert.

  1. Download the tool:

    • Before you begin, you'll need to install a tool called postman-to-openapi. This tool will help you convert your Postman Collection to OpenAPI YAML format. You can install it using npm, a package manager for JavaScript.

    • Open your command line interface (CLI) and run the following command:

    npm i postman-to-openapi -g

    • This command will install the postman-to-openapi tool globally on your system, allowing you to use it from any directory.

  2. Export your Postman Collection as JSON:

    • Open Postman and locate the collection you want to convert.

    • Click on the collection, then click on the "Export" button.

    • Choose "Export as JSON" from the options. This will download your Postman Collection in JSON format to your local machine.

  3. Run the conversion command:

    • Navigate to the directory where you downloaded your Postman Collection JSON file using the CLI.

    • Once you're in the directory, run this command:

    p2o ./path/to/PostmanCollection.json -f ./out_openapi_.yml

    Replace ./path/to/PostmanCollection.json with the actual path to your Postman Collection JSON file. Replace ./out_openapi_.yml with the desired output file path for your OpenAPI YAML file. This is the file where the converted schema will be saved.

  4. Update the YAML file:

    • Once the conversion process is complete, navigate to the directory where you saved the output OpenAPI YAML file.

    • Open the file using a text editor of your choice.

    • In the YAML file, you may need to update certain sections such as basePathUrl and any other variables to match your specific API configuration. These are typically found at the beginning of the YAML file and may include details like the base URL of your API and other parameters.

  5. Save your changes:

    • After making any necessary updates to the YAML file, save the file in your text editor.

By following these steps, you should be able to successfully convert your Postman Collection to OpenAPI YAML format and make any necessary adjustments to the resulting file.

Last updated