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

Upgrade JSON schema validator + fixes #491

Merged
merged 3 commits into from
Oct 28, 2024
Merged

Upgrade JSON schema validator + fixes #491

merged 3 commits into from
Oct 28, 2024

Conversation

Whathecode
Copy link
Member

@Whathecode Whathecode commented Oct 26, 2024

There was an error in the DeviceDeploymentStatus JSON schema which wasn't spotted by the JSON schema validator.

Upgrading to the latest version definitely provides better validation, but in addition also seems to introduce a bug in the evaluation of unevaluatedProperties (networknt/json-schema-validator#1123). For now, I have removed these where it caused validation to fail, thus resulting in less strict/correct schema definitions. If we decide to merge this PR, we need to create a new bug to fix this once the bug is fixed in the schema validator.

On the upside, with the new version of networknt /json-schema-validator it should be possible to use more concise anchor references (#353). I'll add this as a separate commit later.

This didn't seem to fail due to missing evaluation in the currently used version of `com.networknt:json-schema-validator`.
yuanchen233
yuanchen233 previously approved these changes Oct 26, 2024
Copy link
Collaborator

@yuanchen233 yuanchen233 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this bug is fixed, those schemas allows additional properties. (I tried to apply "additionalProperties": false resulting the same error message)

@Whathecode
Copy link
Member Author

Whathecode commented Oct 27, 2024

@yuanchen233 This should be a cleaner workaround, to be resolved in #492.

This has the benefit that extra unexpected properties on concrete types will still correctly fail. And existing properties are properly evaluated. Just a messy/redundant schema definition which shouldn't be necessary.

This seems to have introduced better evaluation of `allOf` and `oneOf` references.

However, it does seem to introduce a bug which causes it not to consider properties in nested schemas more than 1 level deep when evaluating `unevaluatedProperties`: networknt/json-schema-validator#1123

Therefore, a hack was introduced to make sure validation succeeds.. Note that not all concrete types are currently evaluated (#404), so there are many other schemas which would also fail if they were to be evaluated, and they would need to apply a similar fix.
With the upgrade to the latest JSON schema validator, internal anchor references (within a schema) now work. Types which should only be used internally still use the longer paths to `$defs`.

This has the added benefit that these anchors are also evaluated. It turned out that some anchors in `ParticipantGroupStatus` were wrong, and in `DataStreamServiceRequest` one was missing.

Closes #353
Copy link
Collaborator

@yuanchen233 yuanchen233 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there conventions for when to use an anchor and when not?

Are we using anchor for all subschemas? Could you also leave a note/answer to your own question in #353 for future referance? 😀

@Whathecode
Copy link
Member Author

Could you also leave a note/answer to your own question in #353 for future referance? 😀

Of course! 👍🙂

Check the last commit description of this PR. I can't copy paste it now (I'm on phone).

@Whathecode Whathecode merged commit c356f9c into develop Oct 28, 2024
3 checks passed
@Whathecode Whathecode deleted the fix-json-schemas branch October 28, 2024 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants