Response content assertions
Check that responses contain specific values, not just the right shape.
contentassertions
What it does
Asserts concrete values in the response body and headers of the list and detail lead endpoints, using exact matches, contains, oneOf, length limits and a custom Postman assertion. Useful against seeded test data or a mock where the expected values are known.
portman-config.json
{ "version": 1, "tests": { "contractTests": [ { "openApiOperation": "*::/crm/*", "statusSuccess": { "enabled": true } } ], "contentTests": [ { "openApiOperationId": "leadsAll", "responseBodyTests": [ { "key": "data[0].company_name", "value": "Spacex" }, { "key": "data[0].name", "contains": "Musk" }, { "key": "status_code", "oneOf": [ 200, 201 ] }, { "key": "data", "minLength": 1, "maxLength": 20 }, { "key": "service", "assert": "not.to.be.undefined" } ] }, { "openApiOperationId": "leadsOne", "responseBodyTests": [ { "key": "data.websites[*].url", "value": "http://example.com" } ], "responseHeaderTests": [ { "key": "Operation-Location", "contains": "/operations/" } ] } ] }}Run it
terminal
$ npx @apideck/portman -l ./openapi.yaml -c ./portman-config.json -b http://localhost:3050 -n trueNotes
- Use a [*] wildcard in the key to match any object in an array.
- Use notExist: true to assert that a property is absent from the response.