Guides

Filtering operations

Limit which OpenAPI operations Portman converts and tests using an openapi-format filter file with tags, methods, operationIds and flags.

Portman can filter your OpenAPI document before converting it, so the Postman collection only contains the operations you want to test. Pass an openapi-format filter file with --filterFile; every matching item is removed from the document.

Filter by tag

To test only the Leads operations of a CRM spec, remove every other tag. oas-format-filter.json:

json
{  "methods": [],  "tags": ["Companies", "Opportunities", "Contacts", "Pipelines", "Notes", "Users", "Activities"],  "operationIds": [],  "operations": [],  "flags": [],  "flagValues": []}
bash
portman -u https://specs.apideck.com/crm.yml --filterFile ./oas-format-filter.json

Note that the filter lists what to remove, not what to keep.

Filter types

TypeDescriptionExample
methodsOpenAPI methods.["get", "post", "put"]
tagsOpenAPI tags.["Activities", "Users"]
operationIdsOpenAPI operationIds.["leadsAll", "leadsAdd"]
operationsOpenAPI operations.["GET::/crm/leads", "PUT::/crm/leads"]
flagsCustom flags (vendor extensions).["x-exclude", "x-internal"]

Combine types to filter a range of items. All filter options are documented in the openapi-format package and can be tried in the openapi-format playground.

Save the filtered spec

--oaOutput writes the filtered OpenAPI document to a file, which is handy to review or share:

json
{  "url": "https://raw.githubusercontent.com/apideck-libraries/portman/main/examples/cli-filtering/crm.yml",  "baseUrl": "http://localhost:3050",  "output": "./examples/cli-filtering/crm.postman.json",  "oaOutput": "./examples/cli-filtering/filtered-crm.leads.yml",  "filterFile": "./examples/cli-filtering/oas-format-filter.json",  "includeTests": true,  "syncPostman": false,  "runNewman": false}

Filtering versus targeting

  • A filter file removes operations from the collection entirely.
  • Targeting in the Portman config keeps all requests but controls which ones get tests, variables or overwrites, using openApiOperation wildcards and excludeForOperations.

Use filtering to shrink a large spec, and targeting to decide what each request does.