CLI

CLI options

Every Portman CLI flag, with aliases, types and defaults, plus common command examples for converting specs and running tests.

The Portman CLI takes an OpenAPI document as input (-u for a URL or -l for a local file) and accepts flags that control conversion, test generation, output, Postman upload and Newman runs. All of these flags can also be stored in a CLI options file.

Usage

bash
portman -u <url> -l <local> -b <baseUrl> -t <includeTests>

All options

OptionAliasTypeDescription
--helpbooleanShow help.
--versionbooleanShow version number.
--url-ustringURL of the OpenAPI spec to port to a Postman collection.
--local-lstringUse a local OpenAPI spec to port to a Postman collection.
--baseUrl-bstringOverride the spec's base URL to use in Postman.
--output-ostringWrite the Postman collection to an output file.
--oaOutputstringWrite the (filtered) OpenAPI file to an output file.
--runNewman-nbooleanRun Newman on the newly created collection.
--newmanRunOptionsstringJSON stringified object with options for configuring Newman.
--newmanOptionsFilestringPath or URL to a Newman options file.
--newmanIterationData-dstringIteration data to run Newman with the newly created collection.
--localPostmanstringUse a local Postman collection, skipping the OpenAPI conversion.
--syncPostmanbooleanUpload the generated collection to Postman. Default: false.
--syncPostmanCollectionIdsbooleanSynchronise the IDs of newly created Postman collections with those already on Postman, useful for Postman pull requests. Default: false.
--postmanFastSyncbooleanPostman sync creates a new collection (new UID) instead of updating. Default: false.
--postmanRefreshCachebooleanPostman sync refreshes all locally cached Postman API data. Default: false.
--postmanUid-pstringPostman collection UID to upload the generated collection to.
--postmanWorkspaceNamestringPostman workspace name to target for the upload.
--includeTests-tbooleanInject the Portman test suite. Default: true.
--bundleContractTestsbooleanBundle Portman contract tests in a separate folder in Postman. Default: false.
--portmanConfigFile-cstringPath or URL to the Portman config file (portman-config.json).
--postmanConfigFile-sstringPath to the openapi-to-postman config file (postman-config.json).
--filterFilestringPath or URL to the openapi-format filter file (oas-format-filter.json).
--envFilestringPath to the .env file to inject environment variables.
--collectionNamestringOverwrite the OpenAPI title to set the Postman collection name.
--cliOptionsFilestringPath or URL to a Portman CLI options file.
--ignoreCircularRefsbooleanIgnore circular references in the OpenAPI spec. Default: false.
--logAssignVariablesbooleanToggle logging of assigned variables. Default: true.
--warn / --no-warnbooleanToggle warnings for missing openApiOperationIds. Default: true.
--initstringConfigure Portman CLI options interactively.
--extraUnknownFormatsarrayAdd extra unknown formats to JSON schema tests.

Examples

Initialize the Portman CLI configuration interactively:

bash
portman --init

Convert a remotely hosted spec:

bash
portman -u https://specs.apideck.com/crm.yml

Overwrite the base URL in the spec and run Newman:

bash
portman -u https://specs.apideck.com/crm.yml -b http://localhost:3050 -n true

Pass a local data file for Newman to use for iterations:

bash
portman -u https://specs.apideck.com/crm.yml -b http://localhost:3050 -n true -d ./tmp/newman/data/crm.json

Convert a local spec and write the collection to a specific file:

bash
portman -l ./tmp/specs/crm.yml -o ./tmp/specs/crm.postman.json

Skip tests and only generate the collection:

bash
portman -l ./tmp/specs/crm.yml -t false

Filter the OpenAPI document before conversion (see Filtering operations):

bash
portman -u https://specs.apideck.com/crm.yml --filterFile examples/cli-filtering/oas-format-filter.json

Add extra formats to the JSON schema validation. This makes schema validation more lenient and solves problems with unknown formats:

bash
portman -l ./tmp/specs/crm.yml -o ./tmp/specs/crm.postman.json --extraUnknownFormats ulid one two

Pass custom config files, in JSON or YAML:

bash
portman -u https://specs.apideck.com/crm.yml -c ./tmp/crm/portman-config.json -s ./common/postman-config.jsonportman -u https://specs.apideck.com/crm.yml -c ./tmp/crm/portman-config.yaml -s ./common/postman-config.json

Load all options from a file:

bash
portman --cliOptionsFile ./examples/cli-options/portman-cli-options.json

The openapi-to-postman config

The conversion itself is handled by openapi-to-postman. Portman ships a default postman-config.default.json, which is used when you do not pass --postmanConfigFile. If you use a custom Postman config file with Portman 1.28.0 or later, set the parametersResolution option to either "Example" or "Schema". The options requestParametersResolution and exampleParametersResolution are deprecated openapi-to-postman options.