This rule ensures that bodies for “error” responses are adhere to the same convention.
Having errors formatted in the same way significantly simplifies their handling.
The standard-response-errors
rule is designed to ensure that the bodies of
all responses for 4xx and 5xx codes in a schema adhere to the same convention.
Currently supported conventions are:
The configuration is a single string representing the desired convention.
Currently supported values are:
problem-json
- Problem
JSON. This is the default
valuejson-api
- convention, where a response body is a list of JSON:API Error
objectsConfiguration Example
lint:
standard-response-errors:
- error
- problem-json
Good.
paths:
/users:
get:
responses:
"400":
description: Bad Request
content:
application/problem+json:
schema:
type: object
properties:
type:
type: string
title:
type: string
status:
type: integer
detail:
type: string
Bad.
paths:
/users:
get:
responses:
"400":
description: Bad Request
content:
application/json:
schema:
type: object
properties:
error:
type: string
message:
type: string
When your team or organisation has different conventions for formatting errors.
This rule is compatible with all OpenAPI 3.x versions.