This rule ensures that request and response documents in a JSON:API conform to the JSON:API specification.
The json-api/schema-validation
rule is designed to ensure that request and
response documents in a JSON:API conform to the JSON:API specification. This
includes checking the document’s structure, as well as the structure of any
contained resources. This rule is specifically useful for APIs that adhere to
the JSON:API specification.
None.
Good. The following response defines a minimalistic but valid document schema.
---
paths:
/users/current:
get:
responses:
2XX:
content:
application/vnd.api+json:
schema:
type: object
properties:
jsonapi:
type: object
data:
type: object
Bad. The following schema defines string response, which is not a valid type for JSON:API documents.
---
paths:
/users/current:
get:
responses:
2XX:
content:
application/vnd.api+json:
schema:
type: string
You should not use this rule if your API is not compatible with JSON:API.
This rule is compatible with all OpenAPI 3.x version.