Skip to main content

operation-4xx-response

Requires every operation with a response object to include a response key beginning with 4.

AttributeValue
CategoryOperations
MaturitySilver
OpenAPISwagger 2.0; OpenAPI 3.0, 3.1, 3.2
Starter–LenientOff
Recommended–StrictWarning
CompleteError

Intent

Operations should document at least one way a client request can be rejected.

Flags

An operation whose responses object has no key starting with 4.

Does not flag

An operation containing any 4xx or 4XX-style key, or an operation where responses is absent or not an object. The rule checks only the first character, not status validity.

See it fail

responses:
'200':
description: OK

Diagnostic: Operation must have at least one `4XX` response.

Fix it

responses:
'200':
description: OK
'400':
description: Invalid request

Configure

profiles:
default:
rules:
extends: [recommended]
override:
operation-4xx-response: error

Nearby: operation-2xx-response, define-validation-error-response.