operation-success-response
Operation must have at least one "2xx" or "3xx" response.
- Applies to
responses- Selects
#OperationObject- Function
oasOpSuccessResponse- Specs
- OpenAPI 2.0OpenAPI 3.0OpenAPI 3.1OpenAPI 3.2
Use it
This rule ships with OpenLint in spectral:oas. Extending the ruleset turns it on:
extends: spectral:oas
rules:
operation-success-response: warn # or off, or another severity
Definition
As defined in @openlint/openlint-rulesets. Functions show by name.
operation-success-response:
description: Operation must have at least one "2xx" or "3xx" response.
recommended: true
given: '#OperationObject'
then:
field: responses
function: oasOpSuccessResponse
About this rule
Operation must have at least one 2xx or 3xx response. Any API operation (endpoint) can fail, but presumably, it is also meant to do something constructive at some point. If you forget to write out a success case for this API, then this rule will let you know.
Bad Example
paths:
/path:
get:
responses:
418:
description: teapot