Linter rulesOpenAPIjson-api/schema-validation
json-api/schema-validation
Since 0.0.1
This rule ensures that request and response documents in a JSON:API conform to the JSON:API specification.
Rule Details
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.
Configuration
None.
Examples
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
When Not to Use It
You should not use this rule if your API is not compatible with JSON:API.
Compatibility
This rule is compatible with all OpenAPI 3.x version.