Skip to main content

not-error-json-response

Disallows problem-detail JSON media types on 2xx responses.

AttributeValue
CategoryOperations
MaturityGold
OpenAPISwagger 2.0; OpenAPI 3.0, 3.1, 3.2
StarterOff
Lenient–StrictWarning
CompleteError

Intent

Problem details represent failures. Advertising them as successful content blurs the operation's outcome and client handling.

Flags

A response code beginning with 2 when any content key contains the case-sensitive text problem+json.

Does not flag

Non-2xx responses or successful responses whose media types do not contain that text.

See it fail

responses:
'200':
description: OK
content:
application/problem+json:
schema:
type: object

Diagnostic: 2xx responses should not use `application/problem+json`.

Fix it

Use the success representation's media type:

responses:
'200':
description: OK
content:
application/json:
schema:
type: object

Configure

profiles:
default:
rules:
extends: [recommended]
override:
not-error-json-response: error

Nearby: error-response-media-type, operation-4xx-problem-details-rfc7807.