This rule ensures that every request and response in an OpenAPI schema provides
the application/vnd.api+json
media type.
The json-api/content-type
rule is designed to ensure that every request and
response in an OpenAPI schema provides the application/vnd.api+json
media
type. This rule is specifically useful for APIs that adhere to the JSON:API
specification.
None.
Good. By marking the response with the correct media type, API authors enable enhancements specific to JSON:API.
openapi: 3.1.0
info: ...
paths:
/users:
get:
responses:
"200":
description: A list of users.
content:
application/vnd.api+json:
schema:
$ref: "#/components/schemas/UserListResponse"
Bad. Although the response is a valid JSON:API document, it is not obvious from this definition.
openapi: 3.1.0
info: ...
paths:
/users:
get:
responses:
"200":
description: A list of users.
content:
application/json:
schema:
$ref: "#/components/schemas/UserListResponse"
If the API is not meant to be JSON:API compatible.
This rule is compatible with all OpenAPI 3.x version.