networknt / json-schema-validator

A fast Java JSON schema validator that supports draft V4, V6, V7, V2019-09 and V2020-12
Apache License 2.0
807 stars 320 forks source link

Refactor walk #986

Closed justin-tay closed 4 months ago

justin-tay commented 4 months ago

Closes #441, closes #467, closes #841, closes #868, closes #882

This contains breaking changes to those using the walk functionality

When using the walker with defaults the default across a $ref are properly resolved and used.

The behavior for the property listener is now more consistent whether or not validation is enabled. Previously if validation is enabled but the property is null the property listener is not called while if validation is not enabled it will be called. Now the property listener will be called in both scenarios.

The following are the breaking changes to those using the walk functionality. Previously there wasn't a way to get the JsonSchema of the schema that was referenced by the schemaNode and it was unclear what the schemaLocation or evaluationPath was referring to.

WalkEvent Field Change Notes
schemaLocation Removed For keywords: getValidator().getSchemaLocation(). For items and properties: getSchema().getSchemaLocation()
evaluationPath Removed For keywords: getValidator().getEvaluationPath(). For items and properties: getSchema().getEvaluationPath()
schemaNode Removed getSchema().getSchemaNode()
parentSchema Removed getSchema().getParentSchema()
schema New For keywords this is the parent schema of the validator. For items and properties this is the item or property schema being evaluated.
node Renamed instanceNode
currentJsonSchemaFactory Removed getSchema().getValidationContext().getJsonSchemaFactory()
validator New The validator indicated by the keyword.
codecov-commenter commented 4 months ago

Codecov Report

Attention: Patch coverage is 62.03704% with 41 lines in your changes are missing coverage. Please review.

Project coverage is 78.76%. Comparing base (95911ba) to head (65be26c). Report is 1 commits behind head on master.

Files Patch % Lines
...ain/java/com/networknt/schema/utils/JsonNodes.java 52.17% 9 Missing and 2 partials :warning:
...ava/com/networknt/schema/ItemsValidator202012.java 0.00% 7 Missing :warning:
...ava/com/networknt/schema/PrefixItemsValidator.java 0.00% 7 Missing :warning:
...ava/com/networknt/schema/utils/JsonSchemaRefs.java 50.00% 3 Missing and 2 partials :warning:
...main/java/com/networknt/schema/ItemsValidator.java 60.00% 3 Missing and 1 partial :warning:
...main/java/com/networknt/schema/walk/WalkEvent.java 77.77% 2 Missing :warning:
src/main/java/com/networknt/schema/JsonSchema.java 92.30% 0 Missing and 1 partial :warning:
...a/com/networknt/schema/MaxPropertiesValidator.java 0.00% 1 Missing :warning:
...a/com/networknt/schema/MinPropertiesValidator.java 0.00% 1 Missing :warning:
...java/com/networknt/schema/PropertiesValidator.java 93.75% 0 Missing and 1 partial :warning:
... and 1 more

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

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #986 +/- ## ============================================ + Coverage 78.51% 78.76% +0.24% - Complexity 1866 1919 +53 ============================================ Files 169 172 +3 Lines 6088 6197 +109 Branches 1153 1199 +46 ============================================ + Hits 4780 4881 +101 + Misses 871 861 -10 - Partials 437 455 +18 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.