Skip to content

Latest commit

 

History

History
181 lines (145 loc) · 12.4 KB

compatibility.md

File metadata and controls

181 lines (145 loc) · 12.4 KB

Compatibility with JSON Schema versions

Supported Dialects Draft 2020-12 Draft 2019-09 Draft 7 Draft 6 Draft 4

The pattern and format regex 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 such as GraalJS or Joni.

Annotation processing and reporting are implemented. Note that the collection of annotations will have an adverse performance impact.

This implements the Flag, List and Hierarchical output formats defined in the Specification for Machine-Readable Output for JSON Schema Validation and Annotation.

The implementation supports the use of custom keywords, formats, vocabularies and meta-schemas.

Known Issues

There are currently no known issues with the required functionality from the specification.

The following are the tests results after running the JSON Schema Test Suite as at 18 Jun 2024 using version 1.4.1. As the test suite is continously updated, this can result in changes in the results subsequently.

Implementations Overall DRAFT_03 DRAFT_04 DRAFT_06 DRAFT_07 DRAFT_2019_09 DRAFT_2020_12
NetworkNt pass: r:4803 (100.0%) o:2372 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:610 (100.0%) o:251 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:822 (100.0%) o:318 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:906 (100.0%) o:541 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:1220 (100.0%) o:625 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:1245 (100.0%) o:637 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)

Legend

Symbol Meaning
🟢 Fully implemented
🟡 Partially implemented
🔴 Not implemented
🚫 Not defined

Keywords Support

Keyword Draft 4 Draft 6 Draft 7 Draft 2019-09 Draft 2020-12
$anchor 🚫 🚫 🚫 🟢 🟢
$defs 🚫 🚫 🚫 🟢 🟢
$dynamicAnchor 🚫 🚫 🚫 🚫 🟢
$dynamicRef 🚫 🚫 🚫 🚫 🟢
$id 🟢 🟢 🟢 🟢 🟢
$recursiveAnchor 🚫 🚫 🚫 🟢 🚫
$recursiveRef 🚫 🚫 🚫 🟢 🚫
$ref 🟢 🟢 🟢 🟢 🟢
$vocabulary 🚫 🚫 🚫 🟢 🟢
additionalItems 🟢 🟢 🟢 🟢 🟢
additionalProperties 🟢 🟢 🟢 🟢 🟢
allOf 🟢 🟢 🟢 🟢 🟢
anyOf 🟢 🟢 🟢 🟢 🟢
const 🚫 🟢 🟢 🟢 🟢
contains 🚫 🟢 🟢 🟢 🟢
contentEncoding 🚫 🚫 🟢 🟢 🟢
contentMediaType 🚫 🚫 🟢 🟢 🟢
contentSchema 🚫 🚫 🚫 🟢 🟢
definitions 🟢 🟢 🟢 🚫 🚫
dependencies 🟢 🟢 🟢 🚫 🚫
dependentRequired 🚫 🚫 🚫 🟢 🟢
dependentSchemas 🚫 🚫 🚫 🟢 🟢
enum 🟢 🟢 🟢 🟢 🟢
exclusiveMaximum (boolean) 🟢 🚫 🚫 🚫 🚫
exclusiveMaximum (numeric) 🚫 🟢 🟢 🟢 🟢
exclusiveMinimum (boolean) 🟢 🚫 🚫 🚫 🚫
exclusiveMinimum (numeric) 🚫 🟢 🟢 🟢 🟢
if-then-else 🚫 🚫 🟢 🟢 🟢
items 🟢 🟢 🟢 🟢 🟢
maxContains 🚫 🚫 🚫 🟢 🟢
minContains 🚫 🚫 🚫 🟢 🟢
maximum 🟢 🟢 🟢 🟢 🟢
maxItems 🟢 🟢 🟢 🟢 🟢
maxLength 🟢 🟢 🟢 🟢 🟢
maxProperties 🟢 🟢 🟢 🟢 🟢
minimum 🟢 🟢 🟢 🟢 🟢
minItems 🟢 🟢 🟢 🟢 🟢
minLength 🟢 🟢 🟢 🟢 🟢
minProperties 🟢 🟢 🟢 🟢 🟢
multipleOf 🟢 🟢 🟢 🟢 🟢
not 🟢 🟢 🟢 🟢 🟢
oneOf 🟢 🟢 🟢 🟢 🟢
pattern 🟢 🟢 🟢 🟢 🟢
patternProperties 🟢 🟢 🟢 🟢 🟢
prefixItems 🚫 🚫 🚫 🚫 🟢
properties 🟢 🟢 🟢 🟢 🟢
propertyNames 🚫 🟢 🟢 🟢 🟢
readOnly 🚫 🚫 🟢 🟢 🟢
required 🟢 🟢 🟢 🟢 🟢
type 🟢 🟢 🟢 🟢 🟢
unevaluatedItems 🚫 🚫 🚫 🟢 🟢
unevaluatedProperties 🚫 🚫 🚫 🟢 🟢
uniqueItems 🟢 🟢 🟢 🟢 🟢
writeOnly 🚫 🚫 🟢 🟢 🟢

In accordance with the specification, unknown keywords are treated as annotations. This is customizable by configuring a unknown keyword factory on the respective meta-schema.

Content Encoding

Since Draft 2019-09, the contentEncoding keyword does not generate assertions.

Content Media Type

Since Draft 2019-09, the contentMediaType keyword does not generate assertions.

Content Schema

The contentSchema keyword does not generate assertions.

Pattern

By default the pattern keyword uses the JDK regular expression implementation validating regular expressions.

This 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.

The library can be configured to use a ECMA-262 compliant regular expression validator which is implemented using GraalJS or Joni. This can be configured by setting setRegularExpressionFactory to the respective GraalJSRegularExpressionFactory or JoniRegularExpressionFactory instances.

This also requires adding the org.graalvm.js:js or org.jruby.joni:joni dependency.

<dependency>
    <!-- Used to validate ECMA 262 regular expressions -->
    <!-- Approximately 50 MB in dependencies -->
    <!-- GraalJSRegularExpressionFactory -->
    <groupId>org.graalvm.js</groupId>
    <artifactId>js</artifactId>
    <version>${version.graaljs}</version>
</dependency>

<dependency>
    <!-- Used to validate ECMA 262 regular expressions -->
    <!-- Approximately 2 MB in dependencies -->
    <!-- JoniRegularExpressionFactory -->
    <groupId>org.jruby.joni</groupId>
    <artifactId>joni</artifactId>
    <version>${version.joni}</version>
</dependency>

Format

Since Draft 2019-09 the format keyword only generates annotations by default and does not generate assertions.

This can be configured on a schema basis by using a meta schema with the appropriate vocabulary.

Version Vocabulary Value
Draft 2019-09 https://json-schema.org/draft/2019-09/vocab/format true
Draft 2020-12 https://json-schema.org/draft/2020-12/vocab/format-assertion true/false

This behavior can be overridden to generate assertions by setting the setFormatAssertionsEnabled option to true.

Format Draft 4 Draft 6 Draft 7 Draft 2019-09 Draft 2020-12
date 🚫 🚫 🟢 🟢 🟢
date-time 🟢 🟢 🟢 🟢 🟢
duration 🚫 🚫 🚫 🟢 🟢
email 🟢 🟢 🟢 🟢 🟢
hostname 🟢 🟢 🟢 🟢 🟢
idn-email 🚫 🚫 🟢 🟢 🟢
idn-hostname 🚫 🚫 🟢 🟢 🟢
ipv4 🟢 🟢 🟢 🟢 🟢
ipv6 🟢 🟢 🟢 🟢 🟢
iri 🚫 🚫 🟢 🟢 🟢
iri-reference 🚫 🚫 🟢 🟢 🟢
json-pointer 🚫 🟢 🟢 🟢 🟢
relative-json-pointer 🚫 🟢 🟢 🟢 🟢
regex 🚫 🚫 🟢 🟢 🟢
time 🚫 🚫 🟢 🟢 🟢
uri 🟢 🟢 🟢 🟢 🟢
uri-reference 🚫 🟢 🟢 🟢 🟢
uri-template 🚫 🟢 🟢 🟢 🟢
uuid 🚫 🚫 🟢 🟢 🟢
Unknown Formats

When 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).

Footnotes
  1. Note that the validation are only optional for some of the keywords/formats.
  2. Refer to the corresponding JSON schema for more information on whether the keyword/format is optional or not.