xref: /aosp_15_r20/external/json-schema-validator/doc/compatibility.md (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1## Compatibility with JSON Schema versions
2
3[![Supported spec](https://img.shields.io/endpoint?url=https%3A%2F%2Fbowtie.report%2Fbadges%2Fjava-json-schema-validator%2Fsupported_versions.json)](https://bowtie.report/#/implementations/java-json-schema-validator)
4[![Compliance](https://img.shields.io/endpoint?url=https%3A%2F%2Fbowtie.report%2Fbadges%2Fjava-json-schema-validator%2Fcompliance%2Fdraft2020-12.json)](https://bowtie.report/#/dialects/draft2020-12)
5[![Compliance](https://img.shields.io/endpoint?url=https%3A%2F%2Fbowtie.report%2Fbadges%2Fjava-json-schema-validator%2Fcompliance%2Fdraft2019-09.json)](https://bowtie.report/#/dialects/draft2019-09)
6[![Compliance](https://img.shields.io/endpoint?url=https%3A%2F%2Fbowtie.report%2Fbadges%2Fjava-json-schema-validator%2Fcompliance%2Fdraft7.json)](https://bowtie.report/#/dialects/draft7)
7[![Compliance](https://img.shields.io/endpoint?url=https%3A%2F%2Fbowtie.report%2Fbadges%2Fjava-json-schema-validator%2Fcompliance%2Fdraft6.json)](https://bowtie.report/#/dialects/draft6)
8[![Compliance](https://img.shields.io/endpoint?url=https%3A%2F%2Fbowtie.report%2Fbadges%2Fjava-json-schema-validator%2Fcompliance%2Fdraft4.json)](https://bowtie.report/#/dialects/draft4)
9
10The `pattern` validator by default uses the JDK regular expression implementation which is not ECMA-262 compliant and is thus not compliant with the JSON Schema specification. The library can however be configured to use a ECMA-262 compliant regular expression implementation.
11
12Annotation processing and reporting are implemented. Note that the collection of annotations will have an adverse performance impact.
13
14This implements the Flag, List and Hierarchical output formats defined in the [Specification for Machine-Readable Output for JSON Schema Validation and Annotation](https://github.com/json-schema-org/json-schema-spec/blob/8270653a9f59fadd2df0d789f22d486254505bbe/jsonschema-validation-output-machines.md).
15
16The implementation supports the use of custom keywords, formats, vocabularies and meta-schemas.
17
18### Known Issues
19
20There are currently no known issues with the required functionality from the specification.
21
22The following are the tests results after running the [JSON Schema Test Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite) as at 29 Jan 2024 using version 1.3.1. As the test suite is continously updated, this can result in changes in the results subsequently.
23
24| Implementations | Overall                                                                 | DRAFT_03                                                          | DRAFT_04                                                            | DRAFT_06                                                           | DRAFT_07                                                               | DRAFT_2019_09                                                        | DRAFT_2020_12                                                          |
25|-----------------|-------------------------------------------------------------------------|-------------------------------------------------------------------|---------------------------------------------------------------------|--------------------------------------------------------------------|------------------------------------------------------------------------|----------------------------------------------------------------------|------------------------------------------------------------------------|
26| NetworkNt       | pass: r:4703 (100.0%) o:2369 (100.0%)<br>fail: r:0 (0.0%) o:1 (0.0%)    |                                                                   | pass: r:600 (100.0%) o:251 (100.0%)<br>fail: r:0 (0.0%) o:0 (0.0%)  | pass: r:796 (100.0%) o:318 (100.0%)<br>fail: r:0 (0.0%) o:0 (0.0%) | pass: r:880 (100.0%) o:541 (100.0%)<br>fail: r:0 (0.0%) o:0 (0.0%)     | pass: r:1201 (100.0%) o:625 (100.0%)<br>fail: r:0 (0.0%) o:0 (0.0%)  | pass: r:1226 (100.0%) o:634 (99.8%)<br>fail: r:0 (0.0%) o:1 (0.2%)     |
27
28### Legend
29
30| Symbol | Meaning               |
31|:------:|:----------------------|
32|   ��   | Fully implemented     |
33|   ��   | Partially implemented |
34|   ��   | Not implemented       |
35|   ��   | Not defined           |
36
37### Keywords Support
38
39| Keyword                    | Draft 4 | Draft 6 | Draft 7 | Draft 2019-09 | Draft 2020-12 |
40|:---------------------------|:-------:|:-------:|:-------:|:-------------:|:-------------:|
41| $anchor                    | �� | �� | �� | �� | �� |
42| $dynamicAnchor             | �� | �� | �� | �� | �� |
43| $dynamicRef                | �� | �� | �� | �� | �� |
44| $id                        | �� | �� | �� | �� | �� |
45| $recursiveAnchor           | �� | �� | �� | �� | �� |
46| $recursiveRef              | �� | �� | �� | �� | �� |
47| $ref                       | �� | �� | �� | �� | �� |
48| $vocabulary                | �� | �� | �� | �� | �� |
49| additionalItems            | �� | �� | �� | �� | �� |
50| additionalProperties       | �� | �� | �� | �� | �� |
51| allOf                      | �� | �� | �� | �� | �� |
52| anyOf                      | �� | �� | �� | �� | �� |
53| const                      | �� | �� | �� | �� | �� |
54| contains                   | �� | �� | �� | �� | �� |
55| contentEncoding            | �� | �� | �� | �� | �� |
56| contentMediaType           | �� | �� | �� | �� | �� |
57| contentSchema              | �� | �� | �� | �� | �� |
58| definitions                | �� | �� | �� | �� | �� |
59| defs                       | �� | �� | �� | �� | �� |
60| dependencies               | �� | �� | �� | �� | �� |
61| dependentRequired          | �� | �� | �� | �� | �� |
62| dependentSchemas           | �� | �� | �� | �� | �� |
63| enum                       | �� | �� | �� | �� | �� |
64| exclusiveMaximum (boolean) | �� | �� | �� | �� | �� |
65| exclusiveMaximum (numeric) | �� | �� | �� | �� | �� |
66| exclusiveMinimum (boolean) | �� | �� | �� | �� | �� |
67| exclusiveMinimum (numeric) | �� | �� | �� | �� | �� |
68| if-then-else               | �� | �� | �� | �� | �� |
69| items                      | �� | �� | �� | �� | �� |
70| maxContains                | �� | �� | �� | �� | �� |
71| minContains                | �� | �� | �� | �� | �� |
72| maximum                    | �� | �� | �� | �� | �� |
73| maxItems                   | �� | �� | �� | �� | �� |
74| maxLength                  | �� | �� | �� | �� | �� |
75| maxProperties              | �� | �� | �� | �� | �� |
76| minimum                    | �� | �� | �� | �� | �� |
77| minItems                   | �� | �� | �� | �� | �� |
78| minLength                  | �� | �� | �� | �� | �� |
79| minProperties              | �� | �� | �� | �� | �� |
80| multipleOf                 | �� | �� | �� | �� | �� |
81| not                        | �� | �� | �� | �� | �� |
82| oneOf                      | �� | �� | �� | �� | �� |
83| pattern                    | �� | �� | �� | �� | �� |
84| patternProperties          | �� | �� | �� | �� | �� |
85| prefixItems                | �� | �� | �� | �� | �� |
86| properties                 | �� | �� | �� | �� | �� |
87| propertyNames              | �� | �� | �� | �� | �� |
88| readOnly                   | �� | �� | �� | �� | �� |
89| required                   | �� | �� | �� | �� | �� |
90| type                       | �� | �� | �� | �� | �� |
91| unevaluatedItems           | �� | �� | �� | �� | �� |
92| unevaluatedProperties      | �� | �� | �� | �� | �� |
93| uniqueItems                | �� | �� | �� | �� | �� |
94| writeOnly                  | �� | �� | �� | �� | �� |
95
96In accordance with the specification, unknown keywords are treated as annotations. This is customizable by configuring a unknown keyword factory on the respective meta-schema.
97
98#### Content Encoding
99
100Since Draft 2019-09, the `contentEncoding` keyword does not generate assertions.
101
102#### Content Media Type
103
104Since Draft 2019-09, the `contentMediaType` keyword does not generate assertions.
105
106#### Content Schema
107
108The `contentSchema` keyword does not generate assertions.
109
110#### Pattern
111
112By default the `pattern` keyword uses the JDK regular expression implementation validating regular expressions.
113
114This is not ECMA-262 compliant and is thus not compliant with the JSON Schema specification. This is however the more likely desired behavior as other logic will most likely be using the default JDK regular expression implementation to perform downstream processing.
115
116The library can be configured to use a ECMA-262 compliant regular expression validator which is implemented using [joni](https://github.com/jruby/joni). This can be configured by setting `setEcma262Validator` to `true`.
117
118This also requires adding the `joni` dependency.
119
120```xml
121<dependency>
122    <!-- Used to validate ECMA 262 regular expressions -->
123    <groupId>org.jruby.joni</groupId>
124    <artifactId>joni</artifactId>
125    <version>${version.joni}</version>
126</dependency>
127```
128
129#### Format
130
131Since Draft 2019-09 the `format` keyword only generates annotations by default and does not generate assertions.
132
133This can be configured on a schema basis by using a meta schema with the appropriate vocabulary.
134
135| Version               | Vocabulary                                                    | Value             |
136|:----------------------|---------------------------------------------------------------|-------------------|
137| Draft 2019-09         | `https://json-schema.org/draft/2019-09/vocab/format`          | `true`            |
138| Draft 2020-12         | `https://json-schema.org/draft/2020-12/vocab/format-assertion`| `true`/`false`    |
139
140This behavior can be overridden to generate assertions by setting the `setFormatAssertionsEnabled` option to `true`.
141
142| Format                | Draft 4 | Draft 6 | Draft 7 | Draft 2019-09 | Draft 2020-12 |
143|:----------------------|:-------:|:-------:|:-------:|:-------------:|:-------------:|
144| date                  | �� | �� | �� | �� | �� |
145| date-time             | �� | �� | �� | �� | �� |
146| duration              | �� | �� | �� | �� | �� |
147| email                 | �� | �� | �� | �� | �� |
148| hostname              | �� | �� | �� | �� | �� |
149| idn-email             | �� | �� | �� | �� | �� |
150| idn-hostname          | �� | �� | �� | �� | �� |
151| ipv4                  | �� | �� | �� | �� | �� |
152| ipv6                  | �� | �� | �� | �� | �� |
153| iri                   | �� | �� | �� | �� | �� |
154| iri-reference         | �� | �� | �� | �� | �� |
155| json-pointer          | �� | �� | �� | �� | �� |
156| relative-json-pointer | �� | �� | �� | �� | �� |
157| regex                 | �� | �� | �� | �� | �� |
158| time                  | �� | �� | �� | �� | �� |
159| uri                   | �� | �� | �� | �� | �� |
160| uri-reference         | �� | �� | �� | �� | �� |
161| uri-template          | �� | �� | �� | �� | �� |
162| uuid                  | �� | �� | �� | �� | �� |
163
164##### Unknown Formats
165
166When the format assertion vocabularies are used in a meta schema, in accordance to the specification, unknown formats will result in assertions. If the format assertion vocabularies are not used, unknown formats will only result in assertions if the assertions are enabled and if `setStrict("format", true)`.
167
168##### Footnotes
1691. Note that the validation are only optional for some of the keywords/formats.
1702. Refer to the corresponding JSON schema for more information on whether the keyword/format is optional or not.