Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Draft 2020-12 and refactor schema retrieval #931

Conversation

justin-tay
Copy link
Contributor

Closes #920, closes #884, closes #877, closes #855, closes #854, closes #840, closes #742

This PR includes breaking changes.

This adds support for the following required for Draft 2020-12 support

  • $dynamicRef
  • $dynamicAnchor
  • $vocabulary

This refactors the schema retrieval codes as the ID is based on IRI and not URI.
Note that Java does not support IRIs. See https://cr.openjdk.org/%7Edfuchs/writeups/updating-uri/ for details.
The following are removed and replaced by SchemaLoader and SchemaMapper.

  • URIFactory - No replacement. The resolve logic is in AbsoluteIRI.
  • URISchemeFactory - No replacement as URIFactory isn't required anymore.
  • URISchemeFetcher - No replacement. The SchemaLoaders are iterated and called.
  • URITranslator - Replaced by SchemaMapper.
  • URLFactory - No replacement as URIFactory isn't required anymore.
  • URLFetcher - Replaced by UriSchemaLoader.
  • URNURIFactory - No replacement as URIFactory isn't required anymore.

The SchemaLoader and SchemaMapper are configured in the JsonSchemaFactory.Builder.

As per the specification. The format keyword since Draft 2019-09 no longer generates assertions by default.
This can be changed by using a custom meta schema with the relevant $vocabulary or by setting the execution configuration to enable format assertions.

This PR also updates the documentation and includes a section on migrating to newer versions. This also includes miscellaneous fixes.

Functional Comparison

With Changes

Implementations Overall DRAFT_03 DRAFT_04 DRAFT_06 DRAFT_07 DRAFT_2019_09 DRAFT_2020_12
NetworkNt pass: r:4694 (99.8%) o:2369 (100.0%)
fail: r:9 (0.2%) o:1 (0.0%)
pass: r:600 (100.0%) o:251 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:796 (100.0%) o:318 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:880 (100.0%) o:541 (100.0%)
fail: r:0 (0.0%) o:0 (0.0%)
pass: r:1198 (99.8%) o:625 (100.0%)
fail: r:3 (0.2%) o:0 (0.0%)
pass: r:1220 (99.5%) o:634 (99.8%)
fail: r:6 (0.5%) o:1 (0.2%)

Performance Comparison

With Changes

Benchmark Mode Score Score Error (99.9%) Unit
measureDraft_03_SchemaFriend avgt 1.9071 ms/op
measureDraft_04_Everit avgt 1.4849 ms/op
measureDraft_04_Justify avgt 2.0652 ms/op
measureDraft_04_Medeia avgt 1.7569 ms/op
measureDraft_04_NetworkNt avgt 1.2460 ms/op
measureDraft_04_SchemaFriend avgt 1.9748 ms/op
measureDraft_04_Vertx avgt 2.8541 ms/op
measureDraft_06_Everit avgt 1.4505 ms/op
measureDraft_06_Justify avgt 1.8239 ms/op
measureDraft_06_Medeia avgt 1.1763 ms/op
measureDraft_06_NetworkNt avgt 1.0269 ms/op
measureDraft_06_SchemaFriend avgt 2.7054 ms/op
measureDraft_06_Snow avgt 11.193 ms/op
measureDraft_07_Everit avgt 1.7233 ms/op
measureDraft_07_Justify avgt 2.7318 ms/op
measureDraft_07_Medeia avgt 1.6508 ms/op
measureDraft_07_NetworkNt avgt 1.3515 ms/op
measureDraft_07_SchemaFriend avgt 5.6883 ms/op
measureDraft_07_Snow avgt 7.6221 ms/op
measureDraft_07_Vertx avgt 3.8757 ms/op
measureDraft_2019_09_DevHarrel avgt 6.1945 ms/op
measureDraft_2019_09_NetworkNt avgt 2.3548 ms/op
measureDraft_2019_09_SchemaFriend avgt 4.8612 ms/op
measureDraft_2019_09_Snow avgt 19.639 ms/op
measureDraft_2019_09_Vertx avgt 7.1400 ms/op
measureDraft_2020_12_DevHarrel avgt 4.8767 ms/op
measureDraft_2020_12_NetworkNt avgt 2.3653 ms/op
measureDraft_2020_12_SchemaFriend avgt 4.2145 ms/op
measureDraft_2020_12_Skema avgt 6.7389 ms/op
measureDraft_2020_12_Vertx avgt 6.9798 ms/op

@codecov-commenter
Copy link

codecov-commenter commented Jan 26, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 76.06516% with 191 lines in your changes missing coverage. Please review.

Project coverage is 79.04%. Comparing base (f3825f3) to head (90fdfd0).
Report is 98 commits behind head on master.

Files with missing lines Patch % Lines
src/main/java/com/networknt/schema/JsonSchema.java 72.48% 27 Missing and 14 partials ⚠️
...java/com/networknt/schema/DynamicRefValidator.java 62.79% 27 Missing and 5 partials ⚠️
...n/java/com/networknt/schema/JsonSchemaFactory.java 81.74% 9 Missing and 14 partials ⚠️
...a/com/networknt/schema/resource/SchemaLoaders.java 36.00% 16 Missing ⚠️
...com/networknt/schema/resource/UriSchemaLoader.java 46.42% 11 Missing and 4 partials ⚠️
...a/com/networknt/schema/resource/SchemaMappers.java 48.14% 14 Missing ⚠️
...com/networknt/schema/resource/MapSchemaLoader.java 0.00% 11 Missing ⚠️
...c/main/java/com/networknt/schema/RefValidator.java 84.31% 4 Missing and 4 partials ⚠️
...om/networknt/schema/ContentMediaTypeValidator.java 84.37% 3 Missing and 2 partials ⚠️
...networknt/schema/resource/DefaultSchemaLoader.java 84.61% 2 Missing and 2 partials ⚠️
... and 13 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #931      +/-   ##
============================================
+ Coverage     78.66%   79.04%   +0.37%     
- Complexity     1432     1504      +72     
============================================
  Files           136      143       +7     
  Lines          4692     4915     +223     
  Branches        896      932      +36     
============================================
+ Hits           3691     3885     +194     
- Misses          644      670      +26     
- Partials        357      360       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment