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:
{ "methods": [], "tags": ["Companies", "Opportunities", "Contacts", "Pipelines", "Notes", "Users", "Activities"], "operationIds": [], "operations": [], "flags": [], "flagValues": []}portman -u https://specs.apideck.com/crm.yml --filterFile ./oas-format-filter.jsonNote that the filter lists what to remove, not what to keep.
Filter types
| Type | Description | Example |
|---|---|---|
methods | OpenAPI methods. | ["get", "post", "put"] |
tags | OpenAPI tags. | ["Activities", "Users"] |
operationIds | OpenAPI operationIds. | ["leadsAll", "leadsAdd"] |
operations | OpenAPI operations. | ["GET::/crm/leads", "PUT::/crm/leads"] |
flags | Custom 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:
{ "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
openApiOperationwildcards andexcludeForOperations.
Use filtering to shrink a large spec, and targeting to decide what each request does.