standard-response-codes

standard-response-codes

This rule checks whether operations define responses for standard HTTP codes only, as described in RFC 9110.

Rule Details

Defining responses for non-standard codes can lead to confusion and interoperability issues in the API’s structure.

The standard-response-codes rule is designed to ensure that operations define responses for standard HTTP codes only, as described in RFC 9110.

The rule works by iterating over all the operations defined in the schema and checking if they define responses for any non-standard HTTP codes. If such a response is found, the rule raises a warning.

Configuration

None.

Examples

Good.

paths:
  /users:
    get:
      responses:
        "200":
          description: OK
        "400":
          description: Bad Request
        "404":
          description: Not Found

Bad.

paths:
  /users:
    get:
      responses:
        "200":
          description: OK
        "460":
          description: Non-standard Code

When Not to Use It

You may turn this rule off for for internal APIs.

Compatibility

This rule is compatible with all OpenAPI 3.x versions.

← Back to Index