Skip to main content

operation-2xx-response

Requires an operation with responses to include at least one response key beginning with 2.

AttributeValue
CategoryOperations
MaturitySilver
OpenAPISwagger 2.0; OpenAPI 3.0, 3.1, 3.2
StarterWarning
Lenient–CompleteError

Intent

Every operation should document how a successful request is represented.

Flags

An operation with at least one response but no response key starting with 2. Set countDefaultAsSuccess: true to let default satisfy the rule.

Does not flag

Operations with a 2xx key, operations whose response collection is empty, or—when configured—operations containing default.

See it fail

responses:
'400':
description: Invalid request

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

Fix it

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

Configure

profiles:
default:
rules:
extends: [recommended]
override:
operation-2xx-response:
severity: error
countDefaultAsSuccess: true

Nearby: operation-4xx-response, response-code-in-range.