Overview
Because JSON Schema has multiple use cases with different intended consumers, the specification defers the details of output formats to other documents. However, implementations are encouraged to support multiple output formats as required by their target user base.This section defines common terms that should be used in JSON Schema output specifications to align the vernacular across differing formats.
Required Terminology
Output specifications which use the information defined below must use this terminology to describe it. Conversely, output specifications which use these terms must maintain their meaning.Evaluation Path
The evaluation path is the set of keys, starting from the schema root, through which evaluation passes to reach the schema object that produced a specific result. The value must be expressed as a JSON Pointer, and it must include any by-reference applicators such as$ref or $dynamicRef.
Example:
This pointer may not be resolvable on the root schema by the normal JSON Pointer process. It is intended as an indication of the traversal path only.
"evaluationPath".
Schema Location
The schema location is the canonical URI of the schema object plus a JSON Pointer fragment indicating the subschema that produced a result. In contrast with the evaluation path, the schema location must not include by-reference applicators such as$ref or $dynamicRef.
Example:
"schemaLocation".
Instance Location
The instance location is the location of the JSON value within the root instance being validated. The value must be expressed as a JSON Pointer. Example:"instanceLocation".
Output Components
Errors
Errors are textual representations of individual validation failures, often intended for human consumers.This specification contains no requirements for the content of these errors.
- The sources (schema and instance) of a given error are easily identifiable
- The terminology defined by this document is used for identifying locations
Annotations
Many keywords are defined to produce annotations, whether intended for:- Inter-keyword communication - e.g., between
propertiesandunevaluatedProperties - Application consumption - e.g.,
title,description, ordefault
- They can be easily associated with the data defined in the annotation collection section
- The terminology defined by this document is used
Dropped Annotations
A dropped annotation is any annotation produced and subsequently dropped by the evaluation due to an unsuccessful validation result of the containing subschema.When to Include
As the intended purpose for including dropped annotations is debugging, implementations that provide dropped annotations should:- Not provide them as default behavior
- Only include them when explicitly configured to do so
- Include them by default only in debugging tools
- Make them easily distinguishable from retained annotations
- Associate them with the data defined in the annotation collection section
- Use the terminology defined by this document
Example Output Format
Here’s an example of how these concepts might be combined in a structured output:Path Differences
Evaluation Path vs Schema Location
Understanding the difference between these two concepts is crucial: Evaluation Path:- Shows how the validator navigated to reach a schema
- Includes
$refand other reference keywords - May not be a valid JSON Pointer into the schema document
- Useful for understanding the logical flow of validation
- Shows the canonical location of the schema
- Does not include reference keywords
- Always a valid URI + JSON Pointer to the actual schema
- Useful for finding the exact schema definition
name property validation:
- Evaluation Path:
/properties/user/$ref/properties/name - Schema Location:
https://example.com/schema#/$defs/person/properties/name
Implementation Considerations
Performance
Collecting detailed output information can impact performance:Implementations may want to offer different output modes:
- Fast mode: Boolean result only
- Standard mode: Basic errors and annotations
- Debug mode: Full details including dropped annotations and evaluation paths
Interoperability
Using consistent terminology across implementations helps users:- Understand output from different validators
- Build tools that work with multiple implementations
- Learn JSON Schema concepts more easily
Extensibility
Output formats may include additional information beyond what’s defined here, such as:- Performance metrics
- Schema validation details
- Custom keyword outputs
- Implementation-specific metadata
When extending output formats, use the terminology defined here for the standard components to maintain interoperability.