Last updated

operation-4xx-problem-details-rfc7807

Ensures that every operation with (400-499) HTTP response has content-type application/problem+json and fields title and type.

OASCompatibility
2.0
3.0
3.1

API design principles

Problem Details for HTTP APIs are a way to carry machine- readable details of errors in a HTTP response to avoid the need to define new error response formats for HTTP APIs.

Every operation with (400-499) HTTP response should have content-type application/problem+json and fields title and type according to the specification.

Configuration

OptionTypeDescription
severitystringPossible values: off, warn, error. Default off (in recommended configuration).

An example configuration:

styleguide:
  rules:
    operation-4xx-problem-details-rfc7807: error

Examples

Given this configuration:

styleguide:
  rules:
    operation-4xx-problem-details-rfc7807: error

Example of incorrect operation response:

post:
  responses:
    '400':
      content:
        application/json:
          schema:
            type: object
            properties:
              type:
                type: string
              title:
                type: string

Example of correct operation response:

post:
  responses:
    '400':
      content:
        application/problem+json:
          schema:
            type: object
            properties:
              type:
                type: string
              title:
                type: string

Resources