Templates

Strict response validation

Catch undocumented response fields, wrong content types and missing headers.

contractschemaheadersstrict

What it does

Validates the response schema with additionalProperties set to false, so any property that is not documented in the spec fails the test. It also checks the content type, the JSON body and that the required response headers from the spec are present.

portman-config.json
{  "version": 1,  "tests": {    "contractTests": [      {        "openApiOperation": "*::/crm/*",        "statusSuccess": {          "enabled": true        },        "contentType": {          "enabled": true        },        "jsonBody": {          "enabled": true        },        "schemaValidation": {          "enabled": true,          "additionalProperties": false        },        "headersPresent": {          "enabled": true        }      }    ]  },  "globals": {    "stripResponseExamples": true  }}

Run it

terminal
$ npx @apideck/portman -l ./openapi.yaml -c ./portman-config.json -b http://localhost:3050 -n true

Notes

  • A failure can mean your spec is missing a property or your API returns more data than intended.
  • If schema validation trips on custom formats, add them with --extraUnknownFormats.