valid-response-http-status-code
Overview
This rule belongs to the swagger-v2-syntax-validation
ruleset and states that:
The Responses Object key must be a valid HTTP status code or set to 'default'. The key must be enclosed in quotation marks for compatibility between JSON and YAML. If the key is an explicit status code, then it must be valid according to RFC7231 and possibly listed in the registered status codes in the IANA Status Code Registry.
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Error |
Message | Invalid HTTP status code found. |
Code | SWAGGER20SYNTAX_V040 |
Type | Validation |
Rule System | Syntax |
Broad Category | Responses |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | swagger2 swagger syntax validation http status status code code http status responses response |
Suggested Fixes
- Make sure that the value of the HTTP status code is enclosed in single or double quotation marks.
- Ensure that the HTTP status code is valid and falls in the range 1XX - 5XX.
For More Information
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#http-status-codes
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#responses-object
- https://www.rfc-editor.org/rfc/rfc7231#section-6
- https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md
- https://docs.apimatic.io/rulesets/overview/