openapi-json-schema-validation

Since 0.0.1 · In the rulesets: Recommended at error, Strict at error, All at error

This rule validates the document against the JSON Schema the OpenAPI Initiative publishes for its version: OpenAPI 3.0, 3.1 or 3.2.

Rule details

A document that does not match the schema of its version has a typo, a field in the wrong place or a value of the wrong type, and every tool that reads it, this linter included, guesses at what was meant. The rule reports each violation at its position, with the message of the validator.

Parts the reader skips, such as unknown properties, are checked too, also when they nest very deep or hold recursive YAML aliases.

It also reports a schema’s local $ref when its target does not exist. JSON Pointer fragments are resolved within the document, or within the nearest schema resource with an $id; named fragments use that resource’s $anchor or $dynamicAnchor. Recursive references are valid. References in example values, defaults and extensions are data and are not checked. External references are not fetched or checked by this rule.

Examples

Good. The smallest valid document.

openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0
paths: {}

Bad. path is not a field of the OpenAPI object; paths was meant.

openapi: 3.0.0
info:
  title: Sample API
  version: 1.0.0
path: {}

Turn it off or change its severity

In apigenie.yaml, off turns the rule off and warning or error sets its severity; a rule with options takes the severity and the options as a pair, [warning, options]. lint.rules has the details.

commands:
  lint:
    rules:
      openapi-json-schema-validation: off
Was this helpful?