Validating JSON Schema Documents
A valid JSON Schema document is a well-formed document that also conforms to the JSON meta-schema rules that defines the legal syntax of a JSON Schema document.
If a JSON document includes a meta-schema URL in the document root with the "$schema" key, the file will be validated as a JSON Schema against the specified meta-schema.
Quick Reference
- If there is a "$schema": "http://json-schema.org/draft-04/schema" property in the schema root, then Draft 4 will be used.
- If there is a "$schema": "http://json-schema.org/draft-06/schema" property in the schema root, then Draft 6 will be used.
- If there is a "$schema": "http://json-schema.org/draft-07/schema" property in the schema root, then Draft 7 will be used.
- If there is a "$schema": "http://json-schema.org/draft/2019-09/schema" property in the schema root, then 2019-09 will be used.
- If there is a "$schema": "http://json-schema.org/draft/2020-12/schema" property in the schema root, then 2020-12 will be used.
- If there is a "$schema" property in the schema root, but with a different draft value, then an error will be displayed ("could not determine version").
- If none of these are found, then it is validated as a simple JSON instance.
- You could also select the JSON Schema Validator in a JSON validation scenario and it will use the version specified in the JSON Schema, or if a version is not specified, the JSON Schema draft-04 will be used.
For information about how to associate a JSON Schema for the purposes of validation, see Associating a JSON Schema Through a Validation Scenario.
For information about using a JSON Schema to validate documents, see Validating JSON Documents Against JSON Schema or Schematron.
2019-09 and 2020-12 Validator Limitations
The JSON Schema Validator handles all the newly introduced keywords in 2019-09 and
2020-12 specifications. However, there are still some limitations:
- The keywords "$recursiveRef" and "$recursiveAnchor" (2019-09) are not supported. This is also indicated by a validation warning.
- The keyword "$dynamicRef" has the same functionality as "$ref", and "$dynamicAnchor" (2020-12) is not supported. This is also indicated by a validation warning.
- The keywords "unevaluatedProperties" / "unevaluatedItems" can "see through" the subschemas of adjacent keywords "if", "then", "else", but do not know about successfully validated properties / items. This means that all the properties / items defined by those subschemas are considered evaluated.
- The keywords "unevaluatedProperties" / "unevaluatedItems" can "see through" the nested subschemas of adjacent keywords "oneOf", "anyOf", "allOf", but all the properties / items defined by those subschemas are considered evaluated, regardless of other nested restrictions.