
Portman π¨π½βπ
Port OpenAPI Spec to Postman Collection, with contract & variation tests included!
Portman leverages OpenAPI documents, with all its defined API request/response properties, to power your Postman collection. Let Portman do all the work and inject contract & variation tests with a minimum of configuration. Customize the Postman requests & variables with a wide range of options to assign & overwrite variables.
[!IMPORTANT]
Important Change: If you are using version 1.28.0 with a custom Postman config file specified by the--postmanConfigFileflag, please ensure that theparametersResolutionoption is set to either "Example" or "Schema". The optionsrequestParametersResolutionandexampleParametersResolutionare deprecated openapi-to-postman options.
Why use Portman?
Convert your OpenAPI spec to Postman, generate contract & variation tests, upload the Postman collection & run the tests through Newman. Include the Portman CLI as part of an automated process for injecting the power of Portman directly into your CI/CD pipeline.
Features
With Portman, you can:
- Convert an OpenAPI document to a Postman collection
- Support for OpenAPI 3.0
- Support for OpenAPI 3.1
- Extend the Postman collection with capabilities
- Inject Postman Contract Tests - learn more
- Assign collection variables - learn more
- Inject Postman Variation Tests - learn more
- Inject Postman Integration Tests
- Inject Postman with Pre-request & Tests scripts on a collection or operation level - learn more
- Modify Postman requests - learn more here and here
- Fuzz Postman requests - learn more
- Upload the Postman collection to your Postman app - learn more
- Test the Postman collection with Newman - learn more
- Split the configuration into multiple files using $ref
- Manage everything in config file for easy local or CI/CD usage - learn more
Getting started
- Install Portman
- Initialize Portman CLI configuration by running:
$ portman --init
OR
- Install Portman
- Copy
.env.exampleto.envand add environment variables you need available to your collection - Copy/rename and customize each of the ____.default.json config files in the root directory to suit your needs
- Start converting your OpenAPI document to Postman
OR
If you have an existing OpenAPI specification, try running Portman without any special setup to see how it can generate a Postman collection with contract tests with it's default configuration.
- Install Portman
- Run portman on your OpenAPI spec, ie:
npx portman -l my-openapi-spec.yaml- (if your spec is hosted use the
-uparameter, ie:npx portman -u https://petstore3.swagger.io/api/v3/openapi.json
This will generate a postman collection that contains a request for every method:endpoint combination defined in your spec, and include a set of "Contract Tests" for each one. You can learn more about contract tests, and how to examine the generated collection here.
(Running portman with no explicit configuration is the same as running it with this configuration file)
All configuration options to convert from OpenAPI to Postman can be found in the openapi-to-postman package documentation. All configuration options to filter flags/tags/methods/operations/... from OpenAPI can be found in the openapi-format package documentation or using the online openapi-format playground.
Installation
Local Installation (recommended)
You can add the Portman CLI to the node_modules by using:
$ npm install --save @apideck/portman
or using yarn:
$ yarn add @apideck/portman
Note that this will require you to run the Portman CLI with npx @apideck/portman -l your-openapi-file.yaml or, if
you are using an older version of npm, ./node_modules/.bin/portman -l your-openapi-file.yaml.
Global Installation
$ npm install -g @apideck/portman
NPX usage
To execute the CLI without installing it via npm, use the npx method.
$ npx @apideck/portman -l your-openapi-file.yaml
CLI Usage
Usage: -u -l -b -t
Options:
--help Show help [boolean]
--version Show version number [boolean]
--url,-u URL of OAS to port to Postman collection [string]
--local, -l Use local OAS to port to Postman collection [string]
--baseUrl, -b Override spec baseUrl to use in Postman [string]
--output, -o Write the Postman collection to an output file [string]
--oaOutput Write the (filtered) OpenAPI file to an output file [string]
--runNewman, -n Run Newman on newly created collection [boolean]
--newmanRunOptions JSON stringified object to pass options for configuring Newman [string]
--newmanOptionsFile Path/URL to Newman options file to pass options for configuring Newman [string]
--newmanIterationData, -d Iteration data to run Newman with newly created collection [string]
--localPostman Use local Postman collection, skips OpenAPI conversion [string]
--syncPostman Upload generated collection to Postman (default: false) [boolean]
--syncPostmanCollectionIds Synchronises the IDs of newly created postman collections with those already
on Postman, useful when you want to use Postman pull request (default: false) [boolean]
--postmanFastSync Postman sync creates new collection (new UID),instead of update (default: false) [boolean]
--postmanRefreshCache Postman sync will refresh all local cached Postman API data (default: false) [boolean]
--postmanUid, -p Postman collection UID to upload with the generated Postman collection [string]
--postmanWorkspaceName Postman Workspace name to target the upload of the generated Postman collection [string]
--includeTests, -t Inject Portman test suite (default: true) [boolean]
--bundleContractTests Bundle Portman contract tests in a separate folder in Postman (default: false) [boolean]
--portmanConfigFile, -c Path/URL to Portman settings config file (portman-config.json) [string]
--postmanConfigFile,-s Path to openapi-to-postman config file (postman-config.json) [string]
--filterFile Path/URL to openapi-format config file (oas-format-filter.json) [string]
--envFile Path to the .env file to inject environment variables [string]
--collectionName Overwrite OpenAPI title to set the Postman collection name [string]
--cliOptionsFile Path/URL to Portman CLI options file [string]
--ignoreCircularRefs Ignore circular references in OpenAPI spec (default: false)