# openapi-json-schema-validation

Source: https://apigenie.pl/docs/linter/openapi/rules/openapi-json-schema-validation

A rule of the OpenAPI linter, which reads OpenAPI 3.0, 3.1 and 3.2 documents. 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.

```yaml
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.

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