at-least-one-response-code-in-responses
Overview
This rule belongs to the openapi-v3-standards-validation
ruleset and states that:
The Responses Object must contain at least one response code which is recommended to be the response for a successful operation call.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Error |
Message | Responses Object is empty. |
Code | OPENAPI3STANDARDS_V196 |
Type | Validation |
Rule System | Semantic |
Broad Category | Responses |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | openapi3 openapi standards semantic validation responses response |
Suggested Fixes
- Ensure that your Responses Object contains at least one entry.
- If you are looking to add a single entry it should represent the expected status code when the current request/operation on the API service is successful.
- If you are unsure, add 200 as the response code and define its corresponding Response Object.
- Ensure that the entry uses a valid HTTP status code/range or use 'default' instead.
- The Responses Object is expected to cover important successful responses and error cases.
For More Information
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#responses-object:~:text=The%20Responses%20Object%20MUST%20contain%20at%20least%20one%20response%20code%2C%20and%20it%20SHOULD%20be%20the%20response%20for%20a%20successful%20operation%20call.
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#http-status-codes
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#response-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#responses-object:~:text=The%20Responses%20Object%20MUST%20contain%20at%20least%20one%20response%20code%2C%20and%20it%20SHOULD%20be%20the%20response%20for%20a%20successful%20operation%20call.
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#http-status-codes
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#response-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#openapi-specification
- https://docs.apimatic.io/rulesets/overview/