Linter rulesSwagger 2.0operation-success-response
operation-success-response
Since 0.9.0
This rule checks whether every operation of a Swagger 2.0 document declares at least one success response.
Rule Details
Consumers and code generators rely on the success response of an operation to know what a successful call returns. An operation that only documents errors leaves that unspecified.
The operation-success-response rule reports Operation must have at least one success response for every operation whose responses contain no status
code starting with 2 or 3 and no default response.
Configuration
None.
Examples
Good. The operation declares a 200 response.
swagger: '2.0'
info:
title: Pet Store
version: 1.0.0
paths:
/pets:
get:
responses:
'200':
description: A list of pets.
'500':
description: Internal error.
Bad. The operation only declares error responses.
swagger: '2.0'
info:
title: Pet Store
version: 1.0.0
paths:
/pets:
get:
responses:
'400':
description: Invalid request.
'500':
description: Internal error.
When Not to Use It
We recommend to always enable this rule.
Compatibility
This rule is compatible with Swagger 2.0 documents. OpenAPI 3.x documents are linted by the OpenAPI linter, which has a rule of the same name.