openapi-postman-test-generator · cli for node.js
Point it at a Swagger 2.0 or OpenAPI 3.x document and it generates a full Postman collection — auth, example bodies, JSON Schema assertions, and negative tests — ready to run with Newman.
The generator is deterministic. An optional AI planner may propose operation order and variable mappings — it never writes the Postman scripts.
$ openapi-postman generate --spec ./petstore.openapi.yaml --negative Generated 8 requests Collection: ./generated/api.collection.json Environment: ./generated/api.environment.json $ openapi-postman run --collection ./generated/api.collection.json ✓ report.html · junit.xml · newman.json
One route from the fixture used on this page — POST /pets in fixtures/petstore.openapi.yaml — traced from spec to generated request.
/pets: post: summary: Create pet requestBody: content: application/json: schema: { $ref: '#/NewPet' } responses: '201': content: application/json: schema: { $ref: '#/Pet' } NewPet: required: [name] properties: name: { example: Miso } status: { enum: [available, adopted] }
$ref chains, merge allOfpm.test() assertions"method": "POST", "url": "{{baseUrl}}/pets", "auth": { "type": "bearer" }, "body": { "raw": "{ \"name\": \"Miso\", \"status\": \"available\" }" } // event[0].script.exec pm.test("Status code is successful (201)", …) pm.test("Response time is below 2000ms", …) pm.test("Response matches the schema…", …)
The generated collection for the Pets API above, folders and negative tests included — exactly what generate --negative produced for this page.
openapi-postman run executes the collection with Newman and writes three reports:
--oauth-token starts the run by fetching an OAuth2 client credentials tokenDELETE operations when testing against an unfamiliar API--tag keeps the operations that carry one of the tags and --exclude-tag leaves them out; Default names the untagged ones--coverage writes it to a file. coverage --run newman.json says what an actual run passed, failed or never reachedLocation to follow--env-var KEY=VALUE for values such as an OTP--bruno) and a k6 script (--k6), from generate or from a collection with convertopenapi-postman diff lists what changed between two versions of a spec, response headers included, and exits non-zero on a breaking changeA provider-neutral planner can propose operation order and variable mappings from a read-only prompt, with schema-validated output and automatic fallback between providers. The deterministic generator still writes every Postman script.
The GitHub Action generates the collection, writes the coverage to the job summary, runs the tests with Newman and fails the job when a test fails. After the run, the summary also shows what the run covered, and the run-coverage output hands that report to later steps. diff guards the spec itself: it fails the step when the new version breaks clients of the old one.
- uses: vannt-dev/openapi-postman-test-generator@v0.10.0 with: spec: openapi.yaml base-url: http://localhost:3000 # optional negative: true # optional exclude-tag: Internal # optional
$ openapi-postman diff --old ./openapi.main.yaml --new ./openapi.yaml
$ npm install -g openapi-postman-test-generator $ npm install -g newman
$ openapi-postman generate --spec ./openapi.yaml --negative --safe
$ openapi-postman run --collection ./generated/api.collection.json --environment ./generated/api.environment.json