operation-4xx-problem-details-rfc7807
Requires 4xx responses to define an object under application/problem+json with type and title properties.
| Attribute | Value |
|---|---|
| Category | Operations |
| Maturity | Gold |
| OpenAPI | Swagger 2.0; OpenAPI 3.0, 3.1, 3.2 |
| Starter–Recommended | Off |
| Strict | Warning |
| Complete | Error |
Intent
A shared problem-details shape gives clients predictable fields for classifying and displaying request failures.
Flags
Response keys matching 4 followed by two digits or X/x characters when any of these is true:
application/problem+jsonis missing;- that media type has no schema;
- the schema type is not
object; - the schema lacks a
typeproperty; or - the schema lacks a
titleproperty.
One response may produce more than one finding.
Does not flag
Non-4xx responses or a matching response with the required media type and inline object fields.
See it fail
responses:
'400':
description: Invalid request
content:
application/json:
schema:
type: object
Diagnostic: Response `4xx` must have content-type `application/problem+json`.
Fix it
responses:
'400':
description: Invalid request
content:
application/problem+json:
schema:
type: object
properties:
type:
type: string
format: uri
title:
type: string
Configure
profiles:
default:
rules:
extends: [strict]
override:
operation-4xx-problem-details-rfc7807: error
Nearby: error-response-media-type, error-schema-code, error-schema-message.