Skip to main content

invalid-operation-status

Requires response keys to contain only digits or the exact word default.

AttributeValue
CategoryOperations
MaturityPlatinum
OpenAPISwagger 2.0; OpenAPI 3.0, 3.1, 3.2
StarterOff
LenientWarning
Recommended–CompleteError

Intent

Unknown response keys cannot be mapped reliably to HTTP outcomes and are treated as a default response by Specmatic.

Flags

Every path-operation response key that is neither entirely numeric nor exactly default.

Does not flag

Numeric keys and default. This rule does not validate numeric length or range; response-code-in-range handles that.

See it fail

responses:
2xx:
description: Success

Diagnostic: Expected status codes to be numbers or default, but "2xx" was found, defaulting to 'default'

Fix it

Use a concrete status:

responses:
'200':
description: Success

Configure

profiles:
default:
rules:
extends: [recommended]
override:
invalid-operation-status: warn

:::caution Range responses

This rule also rejects OpenAPI range keys such as 4XX, although define-validation-error-response accepts 4XX. Use concrete response codes, or turn off one rule when your contract intentionally uses ranges.

:::

Nearby: response-code-in-range, define-validation-error-response.