operation-4xx-response
Requires every operation with a response object to include a response key beginning with 4.
| Attribute | Value |
|---|---|
| Category | Operations |
| Maturity | Silver |
| OpenAPI | Swagger 2.0; OpenAPI 3.0, 3.1, 3.2 |
| Starter–Lenient | Off |
| Recommended–Strict | Warning |
| Complete | Error |
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.