pm2oa
v1.0.0
Published
postman2openapi CLI
Readme
pm2oa
A lightweight CLI tool to convert Postman collections to OpenAPI specifications using postman2openapi.
This package targets Node.js 18+ because it relies on the built-in fetch API (no polyfill included). Ensure fetch is available when running in custom environments.
Installation
npx pm2oaUsage
Convert from URL
npx pm2oa https://some.postman.spec/Convert from URL to specific output file
npx pm2oa https://some.postman.spec/ -o output.ymlConvert from local JSON file
npx pm2oa postman-spec.jsonForce YAML output regardless of extension
npx pm2oa postman-spec.json --format yamlConvert from stdin
cat postman-spec.json | npx pm2oaor
npx pm2oa < postman-spec.jsonOutput Formats
- JSON (default): Outputs OpenAPI specification as JSON
- YAML: Use
--format yamlor an output path ending with.ymlor.yaml
Options
[input]- Input file path or URL to Postman collection (optional; errors when stdin is empty)-o, --output <file>- Output file path (defaults to stdout)-f, --format <format>- Output format (jsonoryaml)-h, --help- Display help information-V, --version- Display version number
Development
npm run lint– Syntax checkindex.jsnpm test– Smoke test JSON and YAML outputs against a fixture
Publishing
- Releases run the
.github/workflows/publish.ymlworkflow (triggered on release publish and manually viaworkflow_dispatch). - The workflow executes
npm ci, thennpm run lint/npm test, and finallynpm publish --access public --provenancewith theNPM_TOKENrepository secret supplied asNODE_AUTH_TOKEN. - Keep versions bumped before invoking the workflow and verify tests/lint pass locally (
npm run lint,npm test, optionallynpm pack) so the pipeline can succeed without intervention.
