Looking to master JSON Schema for OpenAPI?

A 9+ hour course taught by a member of the JSON Schema Technical Steering Committee

OpenAPI 3.1 Vocabulary

A vocabulary that defines the keywords that the OpenAPI Specification 3.1 adds to the JSON Schema 2020-12 dialect, covering polymorphism hints, XML representation, external documentation, and examples.

To make use of this vocabulary, modify your metaschema to declare the use of this vocabulary using the $vocabulary keyword and evaluate its metaschema. If the vocabulary must be present for an implementation to proceed:

{
  ...
  "$vocabulary": {
    ...
    "https://spec.openapis.org/oas/3.1/vocab/base": true
  },
  "allOf": [
    { "$ref": "https://spec.openapis.org/oas/3.1/meta/base" }
  ]
}

Otherwise, if it is optional for implementations to understand this vocabulary to proceed:

{
  ...
  "$vocabulary": {
    ...
    "https://spec.openapis.org/oas/3.1/vocab/base": false
  },
  "allOf": [
    { "$ref": "https://spec.openapis.org/oas/3.1/meta/base" }
  ]
}

Keywords

Keyword Kind Instance Summary
discriminator Other Object Hints at which of the schemas of an adjacent oneOf, anyOf, or allOf an object instance is expected to satisfy, without affecting the validation outcome.
xml Other Any Describes how the instance that this schema applies to is represented when the payload is serialized as XML.
externalDocs Other Any Points to an external resource that further documents the schema.
example Other Any Declares a single example of an instance that this schema describes, superseded by the examples keyword.