https://github.com/levoai/postman-to-openapi
Convert Postman Collections to Full OpenAPI V3 Specifications
https://github.com/levoai/postman-to-openapi
openapi-specification postman postman-collection
Last synced: about 2 months ago
JSON representation
Convert Postman Collections to Full OpenAPI V3 Specifications
- Host: GitHub
- URL: https://github.com/levoai/postman-to-openapi
- Owner: levoai
- License: apache-2.0
- Created: 2022-01-28T00:35:59.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-21T06:56:36.000Z (over 3 years ago)
- Last Synced: 2024-04-21T16:59:03.434Z (about 2 years ago)
- Topics: openapi-specification, postman, postman-collection
- Language: Python
- Homepage:
- Size: 537 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Postman to OpenAPI

## Synopsis
Postman collections are ubiquitous and invaluable for the functional testing of APIs.
However specialized API tests such as *API Contract Testing*, and *API Security Testing* require proper OpenAPI Specifications as inputs.
This tools converts Postman collections to full featured OpenAPI v3 Specifications, that enable [`Codeless Contract Tests`](https://docs.levo.ai/test-your-app/test-app-schema-conformance), and [`Codeless API Security Tests`](https://docs.levo.ai/test-your-app/test-app-security/choices).
## Usage
1. Install `postman-to-openapi` NPM package
```bash
# See https://www.npmjs.com/package postman-to-openapi for details
sudo npm i postman-to-openapi -g
```
2. Install `json-schema` python package
```bash
pip install genson
```
3. Generate the OpenAPI YAML
```bash
./postman_collection_to_openapi.py
```
> The OpenAPI file will be saved to the same directory as the specified Postman Collection.
4. Generate an enriched OpenAPI Specification
```bash
./enrich_openapi_spec.py
```
> The enriched OpenAPI file will be saved to the same directory as the specified `openapi.yaml`.
- Enrichment does the following:
- Split the specification into multiple files based on given prefix
- Add path parameters to the paths if missing
- Replace undefined response status codes with 200
- Remove redundant `content-type` parameters
## Examples
The `./examples` directory has examples of OpenAPI Specifications generated from Postman Collections (for a couple of well know APIs - [GitLab](https://about.gitlab.com/), and [GoodBank](https://www.postman.com/studentconnects/workspace/learning-apis/documentation/4368270-0efa0ab1-a280-488d-900f-28d724f12635)).