
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
openman-pro
Advanced tools
This project is not ownened by me using the code base to fix bugs for my own use if using it use with caution
A postman to openapi spec conversion tool, which automatically
Other than these, this tool can easily handle ignored fields in responses (explained below)
NOTE Please use postman collection ver 2.1 export (and not 2.0 or earlier). This library only support postman collection 2.1
NOTE This repo needs you to have python 3.5+ installed
pip install openman-pro
To install, simple clone this repo
git clone https://github.com/samcaspus/openman.git
and install
python setup.py install
This tool can be used as a python package or as a standalone cli.
To start, simply type openman --help and it will display help
Usage: openman [OPTIONS] COMMAND [ARGS]...
Convert or mock your postman collection to openapi schema
Options:
--help Show this message and exit.
Commands:
convert
mock
Easy!! Just use convert command (default output is yaml)
openman convert postman-collection.json spec.yaml
Or, you can output to json by
openman convert -f json postman-collection.json spec.yaml
I am using the some cherry on top of the awesome project Connexion
Basically, I am using postman example as mock responses, given the request has matching parameters (query, headers etc.). Even if they do not match, this tool gives out the mock responses for provided schema.
openman mock spec.yaml
Sometimes, your api responses have some data which varies. For instance, consider this response for the api POST /user:
{
"result": {
"timestamp": 1572696732,
"username": "abc",
"tags": {
"tag1" : "something",
"tag3": "somethig else"
},
"some-changing-key": "whatever"
}
}
You do want to record the username, timestamp fields, but what about some-changing-key field? What about fields inside tags? You want to keep the tags key as it will always be included in response, but do not want to keep some-changing-key as it may or maynot appear in responses.
Sometimes you may want to ignore only the values of a key, while sometimes you want the key value pair to be ignored alltogether
For such cases, you may not want to document them. For such purpose, Ignore file is used.
In ignore file, you can document the fields you want the openman to ignore. It uses the jsonpath-rw library and uses its syntax (which is quite easy to learn).
To ignore only values but keep the keys, simple use the jsonpath-rw syntax that points to the key. For ex- $.result.tags.[*] will find everything inside tags field in result object.
To ignore both key and values, simply use the above method, i.e. write your jsonpath-rw regex that matches the path, and append :a to it. For example, if you want to delete everything inside tag including tag field itself, you can do so by: $.result.tags.[*]:a
Taking above example, you want to ignore following fields:
tags (ignore value but NOT the key tags)some-changing-key field (ignore both key and value)You can define them in a file ignore.yaml as such:
schema:
/user:
post:
200:
- '$.result.tags.[*]' //Ignore everything inside tags field
- '$.result.some-changing-key:a' //Ignore 'some-changing-key'. Note the leading :a
and then you can convert your postman collection to openapi spec without these fields:
openman -i ignore.yaml postman-collection.json spec.yaml
PS: Leading :a in jsonpath-rw syntax with ignore both the key and values, otherwise only values are ignored.
The default output conversion format is yaml. However, you can easily change the format to json by:
openman -f json postman-collection.json spec.json
FAQs
A Postman to OpenAPI spec converter with mocking facilities
We found that openman-pro demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.