This rule warns when an operation in an OpenAPI schema does not define any success response, i.e., those corresponding to 2xx or 3xx codes.
It is important to understand when a request to an API was successful. Standard way of representing a success are HTTP status codes.
The operation-success-response
rule is designed to ensure that each operation
in an OpenAPI schema defines a success response. These responses are crucial
as they provide information about the successful execution of the operation.
None.
Good. Operation defines success response using specific status code.
paths:
/users:
get:
responses:
"200":
description: A list of users.
Good. Operation defines success response using generic status code.
paths:
/users:
get:
responses:
2XX:
description: A list of users.
Bad. Operation does not define any success response, thus making it difficult to understand how to use it.
paths:
/users:
get:
responses:
400: {}
We recommend to always enable this rule.
This rule is compatible with all OpenAPI 3.x versions.