Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

postman-to-openapi

joolfe27.2kMIT3.0.1TypeScript support: included

Convert postman collection to OpenAPI spec

swagger, OpenAPI, postman, collection, convert, converter, transform, specification, yml

readme

logo

postman-to-openapi

🛸 Convert Postman Collection v2.1/v2.0 to OpenAPI v3.0.

Or in other words, transform this specification and also this to this one

build codecov npm version js-standard-style CodeQL

Installation

Using npm:

npm i postman-to-openapi

Using yarn:

yarn add postman-to-openapi

To install as a cli just

npm i postman-to-openapi -g

Quick Usage

As a library

// Require Package
const postmanToOpenApi = require('postman-to-openapi')

// Postman Collection Path
const postmanCollection = './path/to/postman/collection.json'
// Output OpenAPI Path
const outputFile = './api/collection.yml'

// Async/await
try {
    const result = await postmanToOpenApi(postmanCollection, outputFile, { defaultTag: 'General' })
    // Without save the result in a file
    const result2 = await postmanToOpenApi(postmanCollection, null, { defaultTag: 'General' })
    console.log(`OpenAPI specs: ${result}`)
} catch (err) {
    console.log(err)
}

// Promise callback style
postmanToOpenApi(postmanCollection, outputFile, { defaultTag: 'General' })
    .then(result => {
        console.log(`OpenAPI specs: ${result}`)
    })
    .catch(err => {
        console.log(err)
    })

As a cli

p2o ./path/to/PostmantoCollection.json -f ./path/to/result.yml -o ./path/to/options.json

Cli Demo

cli demo gif

Documentation

All features, usage instructions and help can be found in the Documentation page

Development

This project use for development:

Use the scripts in package.json:

  • test:unit: Run mocha unit test.
  • test: Execute test:lint plus code coverage.
  • lint: Execute standard lint to review errors in code.
  • lint:fix: Execute standard lint and automatically fix errors.
  • changelog: Update changelog automatically.

Steps to generate the gif demo:

  • Install terminalizer npm install -g terminalizer
  • Start a recording using terminalizer record demo -d 'zsh'
  • Stop recording with Ctrl+D
  • Check demo with terminalizer play demo
  • Adjust delays in demo.yml, change rows to 15 (is the height) and anonymize terminal session.
  • Generate the gif with terminalizer render demo

Husky is configured to avoid push incorrect content to git.

Tags

Nodejs Javascript OpenAPI Postman Newman Collection Transform Convert

License

See the LICENSE file.

changelog

3.0.1 (2023-01-21)

Build System

  • deps: fix dependency vulnerability (859c35c)

3.0.0 (2022-12-26)

⚠ BREAKING CHANGES

  • update version because node.js 12 is not supported anymore

Features

  • add node 19 in pipelines (dfd74cf)

Build System

  • support node.js 18.x (1b202d9)
  • update version because node.js 12 is not supported anymore (b1a46a6)

Tests

  • in Node 19 one of the errors has change so fixed in the test (e4e07f9)

2.9.0 (2022-11-06)

Features

  • allow add operation id to the request (3f86a19)

2.7.2 (2022-11-05)

Features

  • support example body undefined (2e7b31d)

Documentation

2.7.1 (2022-09-24)

Bug Fixes

  • check the url can be undefined Close #224 (cb6e53b)
  • docs table add some spaces (099eb73)

2.7.0 (2022-09-18)

Features

  • disabled but duplicating params (not supported by OpenAPI) (4310197)
  • transform disabled option WIP (b4858a2)

Bug Fixes

  • incorrect conflict in previous merge (9face89)

Documentation

  • update docs about new feature (d6c1141)
  • update typescript definition (253dec7)
  • updates and links (5e92c6d)

2.6.2 (2022-09-17)

Bug Fixes

  • support collections without the headers fields in request close #217 (fa93c35)

2.6.1 (2022-09-17)

Bug Fixes

  • close #216, an error when there exist an empty folder at the end of the collection (4d7424c)

Build System

2.6.0 (2022-08-29)

Features

  • add JSON format support (c16a09f)

Documentation

Build System

2.5.0 (2022-08-28)

Features

  • if no language is chosen in body raw mode then use '/' (473db6b)
  • support now 'text/plain' when body request is raw and language is text (53cee26)

Build System

2.4.1 (2022-07-25)

Features

  • request bodies & examples with json comments (a2df3a6)

Bug Fixes

  • support null body in examples responses (14093e3)
  • trying to fix lint (5e57b58)

Documentation

Build System

2.4.0 (2022-06-18)

Features

  • request bodies & examples with json comments (a2df3a6)

Bug Fixes

Documentation

Build System

2.3.0 (2022-06-02)

Features

  • allowed javascript object as input and output (1f1976c)

Bug Fixes

Documentation

Build System

2.2.1 (2022-03-13)

Bug Fixes

Build System

2.2.0 (2022-02-19)

Features

  • Add error handling in response example parse (acba056)

Bug Fixes

  • update dependencies for moderate vulnerability (f0ccc6f)

Build System

2.1.0 (2022-01-15)

Features

  • allow input as string instead of file path (5dc1a18)

Build System

Documentation

2.0.1 (2022-01-15)

Documentation

  • update reference to node version in readme (d661200)

Build System

2.0.0 (2021-12-20)

⚠ BREAKING CHANGES

  • remove support for node.js 10 as some dependencies doens't support

Features

  • study and test node.js version 17 every dependency is compatible (a4ef018)

Bug Fixes

  • convert collections with collection wrapper attribute (ddc8edc), closes #120 #161

Documentation

Continuous Integration

  • add node 16 to pipeline (d9b7029)
  • add node version 17 to pipelines (fbf7b17)

Build System

  • eslint version revert as fail in node 10 (32bc11d)
  • remove support for node.js 10 as some dependencies doens't support (2ad84c2)
  • update dependencies (7d8ca7e)
  • update deps (exec is not possible to update) (14756b9)
  • update node supported version (3bcb2df)
  • update version (8a02811)
  • update version and some deps (b9cde95)

1.18.0 (2021-10-16)

Bug Fixes

  • convert collections with collection wrapper attribute (ddc8edc), closes #120 #161

Build System

  • update version and some deps (b9cde95)

1.17.5 (2021-10-03)

Bug Fixes

  • Avoid error when some versions of postman export response header with null value. close #152 (8eb6861)

Build System

1.17.4 (2021-09-24)

Bug Fixes

  • fallback to parsing non-json raw body as text (#153) (abb85ec)

Tests

  • add test for supported collection versions (d55abfd)

Build System

1.17.3 (2021-09-18)

Bug Fixes

  • update typescript definition with last added options (4f83072)

Build System

  • update dependencies to vastest versions (513ed85)

1.17.2 (2021-09-04)

Build System

1.17.1 (2021-08-14)

Bug Fixes

Build System

1.17.0 (2021-08-07)

Features

  • support path parameter & replace the value and description (faa7cbc)

Code Refactoring

  • simplify vars processing to align with existing code (f07ec8e)

Documentation

Build System

1.16.1 (2021-08-05)

Bug Fixes

  • fail when collection don't have ´variable´ parameter (bb02ad6)

Build System

  • update version and deps (c95d377)

1.16.0 (2021-08-01)

Features

  • replace variables from postman collection or new option (75f8df1)
  • var replacer first implementation (768e59f)

Documentation

  • update documentation with new replacement feature (9cfd142)

Build System

  • update version for new feature (32cdb47)

1.15.0 (2021-07-30)

Features

  • adding x-www-form-urlencoded support (8311563)

Bug Fixes

  • move import to try to fix erro in gh pages (326c745)
  • put color to the beginning of the css (9cc56b0)

Tests

  • trying to fix docs theme error (8c6428b)

Build System

  • update version and mocha dep (cc4f4c5)

Code Refactoring

  • change collection name (8115bc7)
  • form data drop encoding section from and removed require code (9994c8d)
  • improving the mapFormData function (a85eef6)

Documentation

  • mention new feature about "x-www-form-urlencoded" (2c38fd9)

1.14.0 (2021-07-24)

Features

  • adding support for formdata (547b137)

Bug Fixes

Tests

Code Refactoring

  • little refactor to follow our code style and 100% coverage. Support for file types (b569785)

Documentation

  • update new feature for parse "form-data" (4699d50)

Build System

1.13.0 (2021-07-16)

Features

  • parse API response from postman examples (b731f4e)

Documentation

  • update docs about responses (aa61018)

Build System

  • update deps and version (65991ee)

1.12.1 (2021-06-11)

Bug Fixes

  • remove deep with vulnerability (56877cc)

1.12.0 (2021-06-05)

Features

  • support for auth method at operation/request level Close #40 (a8c4d17)

Build System

Documentation

1.11.0 (2021-05-31)

Features

Documentation

  • update docs with new field (3aa907f)

1.10.0 (2021-05-27)

Features

  • allow request with empty URLs (just skip) (6e589d0)

Build System

1.9.2 (2021-05-19)

Bug Fixes

  • use export default for the main function in ts (baa3173)

1.9.1 (2021-05-19)

Bug Fixes

  • ts definition should be upload with the package (0c4610d)

1.9.0 (2021-05-18)

Features

  • add ts definitions to library (36cf16b)

Bug Fixes

Documentation

Tests

  • check that library don't fail when license and contact are empty objects (4d9b400)

Build System

1.8.0 (2021-04-30)

Features

Bug Fixes

  • avoid fail body.raw is empty string Close #101 (1c376cf)
  • some adaptions to use husky (39d1a35)

Build System

Code Refactoring

  • only one file and ass more test (1c440da)

Documentation

1.7.3 (2021-04-24)

Features

Bug Fixes

  • avoid fail body.raw is empty string Close #101 (1c376cf)
  • some adaptions to use husky (39d1a35)

Build System

1.7.1 (2021-03-30)

Bug Fixes

  • vulnerability high fixed in deps (2e4a2cb)

Documentation

1.7.0 (2021-03-28)

Features

  • add support for nested folders (4f5ee97)
  • added concat and separator option to folder tags calculation (4513095)
  • support empty folders Close #89 (6397d7c)

Bug Fixes

  • lint error fixes (de025fd)
  • remove not needed code for feature (48d7952)

Tests

  • add complex folder structure test (56d00df)

Documentation

Miscellaneous Chores

Build System

1.6.1 (2021-03-14)

Build System

  • update several dependencies (bff147f)

1.5.1 (2020-10-01)

Documentation

  • update docs about postman collection version (7ab3ef5)

Build System

1.5.0 (2020-10-01)

Features

  • support postman collection v2 (1d9da47), closes #20

Continuous Integration

Build System

  • update version to 1.5.0 (c3267a8)

1.4.1 (2020-09-12)

Documentation

  • update links to OpenAPI specification (2b66366)

1.4.0 (2020-08-25)

Features

Bug Fixes

1.3.0 (2020-08-23)

Features

Bug Fixes

  • badge url for build fixed (2f14a29)
  • dependabot alert serialize-javascript (be35516)
  • vulnerability fixed (0771a2e)

Tests

  • improve coverage of license and contact (a5662e3)

Documentation

  • complete section "Postman collection examples" #58 (016a749)
  • fix documentation code examples (8efbdda)

Build System

1.2.0 (2020-08-03)

Features

Bug Fixes

Documentation

Code Refactoring

1.1.0 (2020-07-28)

Bug Fixes

  • resource file name in tests (32024e5)

Features

1.0.0 (2020-07-01)

Bug Fixes

  • error in gitignore file name (5bc80d3)

Features

  • add changelog and auto generation (a317c2a)
  • basic structure conversion (05080d9)
  • test engine setup (8ed2375)

Reverts

  • Revert "Testing commit lint" (bd7d8c5)