-
Notifications
You must be signed in to change notification settings - Fork 317
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
Inconsistent validation error since 1.0.82 #824
Comments
The validators get loaded into a TreeMap and sorted based on the type of validation performed. This is done because the standard requires that some validations be performed before others. For example,
|
I have a pull request that fixes this. The issue in this particular case isn't the order of the validators, because even after ensuring a deterministic order, this still happens. The primary cause is these lines json-schema-validator/src/main/java/com/networknt/schema/AnyOfValidator.java Lines 75 to 83 in 0c14a7a
The main reason is that This means that on the first run, In the second run, Another issue is that actually the error message built should be that of the type validator, ie. the type validator should be called with validate to generate the actual message instead of using the message of the anyOf validator as the There are actually other issues for instance
Where |
Greetings -
Similar to the use case described in #285, we're looking to validate a schema against the specification meta schema to ensure it is syntactically valid. And then later on, different JSON payloads are validated against the first schema to ensure they conform.
Based on the comments of #313, I see there may be some issues validating with the
2019-09
spec that we're using. That said, we've noticed some strange behavior since version1.0.82
that seems like a different problem.I've made an example test case here with the results from different versions of the library. I think due to changes in how the
anyOf
keyword is handled, different error messages are returned across the library versions. But in1.0.82
and later, we're getting an inconsistent error message back. The first time a schema is validated returns one error, and then if the same schema is validated again the error response is different which is not what was expected or happening previously.The first call returns
$.type: string found, array expected
and subsequent calls return$.type: should be valid to any of the schemas array
instead.The text was updated successfully, but these errors were encountered: