xref: /aosp_15_r20/external/json-schema-validator/doc/compatibility.md (revision 78c4dd6aa35290980cdcd1623a7e337e8d021c7c)
1*78c4dd6aSAndroid Build Coastguard Worker## Compatibility with JSON Schema versions
2*78c4dd6aSAndroid Build Coastguard Worker
3*78c4dd6aSAndroid Build Coastguard Worker[![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*78c4dd6aSAndroid Build Coastguard Worker[![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*78c4dd6aSAndroid Build Coastguard Worker[![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*78c4dd6aSAndroid Build Coastguard Worker[![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*78c4dd6aSAndroid Build Coastguard Worker[![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*78c4dd6aSAndroid Build Coastguard Worker[![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*78c4dd6aSAndroid Build Coastguard Worker
10*78c4dd6aSAndroid Build Coastguard WorkerThe `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*78c4dd6aSAndroid Build Coastguard Worker
12*78c4dd6aSAndroid Build Coastguard WorkerAnnotation processing and reporting are implemented. Note that the collection of annotations will have an adverse performance impact.
13*78c4dd6aSAndroid Build Coastguard Worker
14*78c4dd6aSAndroid Build Coastguard WorkerThis 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*78c4dd6aSAndroid Build Coastguard Worker
16*78c4dd6aSAndroid Build Coastguard WorkerThe implementation supports the use of custom keywords, formats, vocabularies and meta-schemas.
17*78c4dd6aSAndroid Build Coastguard Worker
18*78c4dd6aSAndroid Build Coastguard Worker### Known Issues
19*78c4dd6aSAndroid Build Coastguard Worker
20*78c4dd6aSAndroid Build Coastguard WorkerThere are currently no known issues with the required functionality from the specification.
21*78c4dd6aSAndroid Build Coastguard Worker
22*78c4dd6aSAndroid Build Coastguard WorkerThe 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*78c4dd6aSAndroid Build Coastguard Worker
24*78c4dd6aSAndroid Build Coastguard Worker| Implementations | Overall                                                                 | DRAFT_03                                                          | DRAFT_04                                                            | DRAFT_06                                                           | DRAFT_07                                                               | DRAFT_2019_09                                                        | DRAFT_2020_12                                                          |
25*78c4dd6aSAndroid Build Coastguard Worker|-----------------|-------------------------------------------------------------------------|-------------------------------------------------------------------|---------------------------------------------------------------------|--------------------------------------------------------------------|------------------------------------------------------------------------|----------------------------------------------------------------------|------------------------------------------------------------------------|
26*78c4dd6aSAndroid Build Coastguard Worker| 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*78c4dd6aSAndroid Build Coastguard Worker
28*78c4dd6aSAndroid Build Coastguard Worker### Legend
29*78c4dd6aSAndroid Build Coastguard Worker
30*78c4dd6aSAndroid Build Coastguard Worker| Symbol | Meaning               |
31*78c4dd6aSAndroid Build Coastguard Worker|:------:|:----------------------|
32*78c4dd6aSAndroid Build Coastguard Worker|   ��   | Fully implemented     |
33*78c4dd6aSAndroid Build Coastguard Worker|   ��   | Partially implemented |
34*78c4dd6aSAndroid Build Coastguard Worker|   ��   | Not implemented       |
35*78c4dd6aSAndroid Build Coastguard Worker|   ��   | Not defined           |
36*78c4dd6aSAndroid Build Coastguard Worker
37*78c4dd6aSAndroid Build Coastguard Worker### Keywords Support
38*78c4dd6aSAndroid Build Coastguard Worker
39*78c4dd6aSAndroid Build Coastguard Worker| Keyword                    | Draft 4 | Draft 6 | Draft 7 | Draft 2019-09 | Draft 2020-12 |
40*78c4dd6aSAndroid Build Coastguard Worker|:---------------------------|:-------:|:-------:|:-------:|:-------------:|:-------------:|
41*78c4dd6aSAndroid Build Coastguard Worker| $anchor                    | �� | �� | �� | �� | �� |
42*78c4dd6aSAndroid Build Coastguard Worker| $dynamicAnchor             | �� | �� | �� | �� | �� |
43*78c4dd6aSAndroid Build Coastguard Worker| $dynamicRef                | �� | �� | �� | �� | �� |
44*78c4dd6aSAndroid Build Coastguard Worker| $id                        | �� | �� | �� | �� | �� |
45*78c4dd6aSAndroid Build Coastguard Worker| $recursiveAnchor           | �� | �� | �� | �� | �� |
46*78c4dd6aSAndroid Build Coastguard Worker| $recursiveRef              | �� | �� | �� | �� | �� |
47*78c4dd6aSAndroid Build Coastguard Worker| $ref                       | �� | �� | �� | �� | �� |
48*78c4dd6aSAndroid Build Coastguard Worker| $vocabulary                | �� | �� | �� | �� | �� |
49*78c4dd6aSAndroid Build Coastguard Worker| additionalItems            | �� | �� | �� | �� | �� |
50*78c4dd6aSAndroid Build Coastguard Worker| additionalProperties       | �� | �� | �� | �� | �� |
51*78c4dd6aSAndroid Build Coastguard Worker| allOf                      | �� | �� | �� | �� | �� |
52*78c4dd6aSAndroid Build Coastguard Worker| anyOf                      | �� | �� | �� | �� | �� |
53*78c4dd6aSAndroid Build Coastguard Worker| const                      | �� | �� | �� | �� | �� |
54*78c4dd6aSAndroid Build Coastguard Worker| contains                   | �� | �� | �� | �� | �� |
55*78c4dd6aSAndroid Build Coastguard Worker| contentEncoding            | �� | �� | �� | �� | �� |
56*78c4dd6aSAndroid Build Coastguard Worker| contentMediaType           | �� | �� | �� | �� | �� |
57*78c4dd6aSAndroid Build Coastguard Worker| contentSchema              | �� | �� | �� | �� | �� |
58*78c4dd6aSAndroid Build Coastguard Worker| definitions                | �� | �� | �� | �� | �� |
59*78c4dd6aSAndroid Build Coastguard Worker| defs                       | �� | �� | �� | �� | �� |
60*78c4dd6aSAndroid Build Coastguard Worker| dependencies               | �� | �� | �� | �� | �� |
61*78c4dd6aSAndroid Build Coastguard Worker| dependentRequired          | �� | �� | �� | �� | �� |
62*78c4dd6aSAndroid Build Coastguard Worker| dependentSchemas           | �� | �� | �� | �� | �� |
63*78c4dd6aSAndroid Build Coastguard Worker| enum                       | �� | �� | �� | �� | �� |
64*78c4dd6aSAndroid Build Coastguard Worker| exclusiveMaximum (boolean) | �� | �� | �� | �� | �� |
65*78c4dd6aSAndroid Build Coastguard Worker| exclusiveMaximum (numeric) | �� | �� | �� | �� | �� |
66*78c4dd6aSAndroid Build Coastguard Worker| exclusiveMinimum (boolean) | �� | �� | �� | �� | �� |
67*78c4dd6aSAndroid Build Coastguard Worker| exclusiveMinimum (numeric) | �� | �� | �� | �� | �� |
68*78c4dd6aSAndroid Build Coastguard Worker| if-then-else               | �� | �� | �� | �� | �� |
69*78c4dd6aSAndroid Build Coastguard Worker| items                      | �� | �� | �� | �� | �� |
70*78c4dd6aSAndroid Build Coastguard Worker| maxContains                | �� | �� | �� | �� | �� |
71*78c4dd6aSAndroid Build Coastguard Worker| minContains                | �� | �� | �� | �� | �� |
72*78c4dd6aSAndroid Build Coastguard Worker| maximum                    | �� | �� | �� | �� | �� |
73*78c4dd6aSAndroid Build Coastguard Worker| maxItems                   | �� | �� | �� | �� | �� |
74*78c4dd6aSAndroid Build Coastguard Worker| maxLength                  | �� | �� | �� | �� | �� |
75*78c4dd6aSAndroid Build Coastguard Worker| maxProperties              | �� | �� | �� | �� | �� |
76*78c4dd6aSAndroid Build Coastguard Worker| minimum                    | �� | �� | �� | �� | �� |
77*78c4dd6aSAndroid Build Coastguard Worker| minItems                   | �� | �� | �� | �� | �� |
78*78c4dd6aSAndroid Build Coastguard Worker| minLength                  | �� | �� | �� | �� | �� |
79*78c4dd6aSAndroid Build Coastguard Worker| minProperties              | �� | �� | �� | �� | �� |
80*78c4dd6aSAndroid Build Coastguard Worker| multipleOf                 | �� | �� | �� | �� | �� |
81*78c4dd6aSAndroid Build Coastguard Worker| not                        | �� | �� | �� | �� | �� |
82*78c4dd6aSAndroid Build Coastguard Worker| oneOf                      | �� | �� | �� | �� | �� |
83*78c4dd6aSAndroid Build Coastguard Worker| pattern                    | �� | �� | �� | �� | �� |
84*78c4dd6aSAndroid Build Coastguard Worker| patternProperties          | �� | �� | �� | �� | �� |
85*78c4dd6aSAndroid Build Coastguard Worker| prefixItems                | �� | �� | �� | �� | �� |
86*78c4dd6aSAndroid Build Coastguard Worker| properties                 | �� | �� | �� | �� | �� |
87*78c4dd6aSAndroid Build Coastguard Worker| propertyNames              | �� | �� | �� | �� | �� |
88*78c4dd6aSAndroid Build Coastguard Worker| readOnly                   | �� | �� | �� | �� | �� |
89*78c4dd6aSAndroid Build Coastguard Worker| required                   | �� | �� | �� | �� | �� |
90*78c4dd6aSAndroid Build Coastguard Worker| type                       | �� | �� | �� | �� | �� |
91*78c4dd6aSAndroid Build Coastguard Worker| unevaluatedItems           | �� | �� | �� | �� | �� |
92*78c4dd6aSAndroid Build Coastguard Worker| unevaluatedProperties      | �� | �� | �� | �� | �� |
93*78c4dd6aSAndroid Build Coastguard Worker| uniqueItems                | �� | �� | �� | �� | �� |
94*78c4dd6aSAndroid Build Coastguard Worker| writeOnly                  | �� | �� | �� | �� | �� |
95*78c4dd6aSAndroid Build Coastguard Worker
96*78c4dd6aSAndroid Build Coastguard WorkerIn 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*78c4dd6aSAndroid Build Coastguard Worker
98*78c4dd6aSAndroid Build Coastguard Worker#### Content Encoding
99*78c4dd6aSAndroid Build Coastguard Worker
100*78c4dd6aSAndroid Build Coastguard WorkerSince Draft 2019-09, the `contentEncoding` keyword does not generate assertions.
101*78c4dd6aSAndroid Build Coastguard Worker
102*78c4dd6aSAndroid Build Coastguard Worker#### Content Media Type
103*78c4dd6aSAndroid Build Coastguard Worker
104*78c4dd6aSAndroid Build Coastguard WorkerSince Draft 2019-09, the `contentMediaType` keyword does not generate assertions.
105*78c4dd6aSAndroid Build Coastguard Worker
106*78c4dd6aSAndroid Build Coastguard Worker#### Content Schema
107*78c4dd6aSAndroid Build Coastguard Worker
108*78c4dd6aSAndroid Build Coastguard WorkerThe `contentSchema` keyword does not generate assertions.
109*78c4dd6aSAndroid Build Coastguard Worker
110*78c4dd6aSAndroid Build Coastguard Worker#### Pattern
111*78c4dd6aSAndroid Build Coastguard Worker
112*78c4dd6aSAndroid Build Coastguard WorkerBy default the `pattern` keyword uses the JDK regular expression implementation validating regular expressions.
113*78c4dd6aSAndroid Build Coastguard Worker
114*78c4dd6aSAndroid Build Coastguard WorkerThis 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*78c4dd6aSAndroid Build Coastguard Worker
116*78c4dd6aSAndroid Build Coastguard WorkerThe 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*78c4dd6aSAndroid Build Coastguard Worker
118*78c4dd6aSAndroid Build Coastguard WorkerThis also requires adding the `joni` dependency.
119*78c4dd6aSAndroid Build Coastguard Worker
120*78c4dd6aSAndroid Build Coastguard Worker```xml
121*78c4dd6aSAndroid Build Coastguard Worker<dependency>
122*78c4dd6aSAndroid Build Coastguard Worker    <!-- Used to validate ECMA 262 regular expressions -->
123*78c4dd6aSAndroid Build Coastguard Worker    <groupId>org.jruby.joni</groupId>
124*78c4dd6aSAndroid Build Coastguard Worker    <artifactId>joni</artifactId>
125*78c4dd6aSAndroid Build Coastguard Worker    <version>${version.joni}</version>
126*78c4dd6aSAndroid Build Coastguard Worker</dependency>
127*78c4dd6aSAndroid Build Coastguard Worker```
128*78c4dd6aSAndroid Build Coastguard Worker
129*78c4dd6aSAndroid Build Coastguard Worker#### Format
130*78c4dd6aSAndroid Build Coastguard Worker
131*78c4dd6aSAndroid Build Coastguard WorkerSince Draft 2019-09 the `format` keyword only generates annotations by default and does not generate assertions.
132*78c4dd6aSAndroid Build Coastguard Worker
133*78c4dd6aSAndroid Build Coastguard WorkerThis can be configured on a schema basis by using a meta schema with the appropriate vocabulary.
134*78c4dd6aSAndroid Build Coastguard Worker
135*78c4dd6aSAndroid Build Coastguard Worker| Version               | Vocabulary                                                    | Value             |
136*78c4dd6aSAndroid Build Coastguard Worker|:----------------------|---------------------------------------------------------------|-------------------|
137*78c4dd6aSAndroid Build Coastguard Worker| Draft 2019-09         | `https://json-schema.org/draft/2019-09/vocab/format`          | `true`            |
138*78c4dd6aSAndroid Build Coastguard Worker| Draft 2020-12         | `https://json-schema.org/draft/2020-12/vocab/format-assertion`| `true`/`false`    |
139*78c4dd6aSAndroid Build Coastguard Worker
140*78c4dd6aSAndroid Build Coastguard WorkerThis behavior can be overridden to generate assertions by setting the `setFormatAssertionsEnabled` option to `true`.
141*78c4dd6aSAndroid Build Coastguard Worker
142*78c4dd6aSAndroid Build Coastguard Worker| Format                | Draft 4 | Draft 6 | Draft 7 | Draft 2019-09 | Draft 2020-12 |
143*78c4dd6aSAndroid Build Coastguard Worker|:----------------------|:-------:|:-------:|:-------:|:-------------:|:-------------:|
144*78c4dd6aSAndroid Build Coastguard Worker| date                  | �� | �� | �� | �� | �� |
145*78c4dd6aSAndroid Build Coastguard Worker| date-time             | �� | �� | �� | �� | �� |
146*78c4dd6aSAndroid Build Coastguard Worker| duration              | �� | �� | �� | �� | �� |
147*78c4dd6aSAndroid Build Coastguard Worker| email                 | �� | �� | �� | �� | �� |
148*78c4dd6aSAndroid Build Coastguard Worker| hostname              | �� | �� | �� | �� | �� |
149*78c4dd6aSAndroid Build Coastguard Worker| idn-email             | �� | �� | �� | �� | �� |
150*78c4dd6aSAndroid Build Coastguard Worker| idn-hostname          | �� | �� | �� | �� | �� |
151*78c4dd6aSAndroid Build Coastguard Worker| ipv4                  | �� | �� | �� | �� | �� |
152*78c4dd6aSAndroid Build Coastguard Worker| ipv6                  | �� | �� | �� | �� | �� |
153*78c4dd6aSAndroid Build Coastguard Worker| iri                   | �� | �� | �� | �� | �� |
154*78c4dd6aSAndroid Build Coastguard Worker| iri-reference         | �� | �� | �� | �� | �� |
155*78c4dd6aSAndroid Build Coastguard Worker| json-pointer          | �� | �� | �� | �� | �� |
156*78c4dd6aSAndroid Build Coastguard Worker| relative-json-pointer | �� | �� | �� | �� | �� |
157*78c4dd6aSAndroid Build Coastguard Worker| regex                 | �� | �� | �� | �� | �� |
158*78c4dd6aSAndroid Build Coastguard Worker| time                  | �� | �� | �� | �� | �� |
159*78c4dd6aSAndroid Build Coastguard Worker| uri                   | �� | �� | �� | �� | �� |
160*78c4dd6aSAndroid Build Coastguard Worker| uri-reference         | �� | �� | �� | �� | �� |
161*78c4dd6aSAndroid Build Coastguard Worker| uri-template          | �� | �� | �� | �� | �� |
162*78c4dd6aSAndroid Build Coastguard Worker| uuid                  | �� | �� | �� | �� | �� |
163*78c4dd6aSAndroid Build Coastguard Worker
164*78c4dd6aSAndroid Build Coastguard Worker##### Unknown Formats
165*78c4dd6aSAndroid Build Coastguard Worker
166*78c4dd6aSAndroid Build Coastguard WorkerWhen 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*78c4dd6aSAndroid Build Coastguard Worker
168*78c4dd6aSAndroid Build Coastguard Worker##### Footnotes
169*78c4dd6aSAndroid Build Coastguard Worker1. Note that the validation are only optional for some of the keywords/formats.
170*78c4dd6aSAndroid Build Coastguard Worker2. Refer to the corresponding JSON schema for more information on whether the keyword/format is optional or not.