mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 04:21:09 +00:00
2.2 KiB
2.2 KiB
slug
| slug |
|---|
| /docs/cli/rules/operation-4xx-problem-details-rfc7807 |
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.
| OAS | Compatibility |
|---|---|
| 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
| Option | Type | Description |
|---|---|---|
| severity | string | Possible 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