You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The OneOf Validator iterates through the validators for each choice in OneOf and validates.
When it encounters the second "valid" schema element, it returns a validation error:
{ "error" : {"statusCode":400,"code":"ERR11004","message":"VALIDATOR_SCHEMA","description":"Schema Validation Error - $.search: should be valid to one and only one of the schemas ","severity":"ERROR"} }
In this case, the matching element was the 8th out of 11th, however the code analyzed them one by one and failed in the second one already, where only the 8th is a true match.
The issue is in the PropertiesValidator, where it tries to find an entry by a key and does not find it.
It treats the "not found" as normal, instead of issuing an error and letting the OneOf Validator handle it gracefully (in this ignore it)
...
JsonNode propertyNode = node.get(entry.getKey());
if (propertyNode != null) {
errors.addAll(propertySchema.validate(propertyNode, rootNode, at + "." + entry.getKey()));
...
Proposed resolution includes the issuance of an error when property node does not match and letting the caller in the recursive chain handle it.
It must be properly validated and ascertained that there are no side-effects.
It is a showstopper for a number of APIs at a client site.
The text was updated successfully, but these errors were encountered:
The fix can be reused and expanded upon in other validators, not only OneOf.
It revolves on how property validator handles missing nodes.
For some validators, the expectation is "ignore" which means success, for others "error".
NOTE: VALIDATORS must preserve the flag from the validators before, respectively following, therefore OneOf saves then re-sets the treat missing node as error, leaving other validators unaffected.
A document will add more details in the upcoming days in doc.networknt.com
From the OpenAPI 3.0 specification document, oneOf – validates the value against exactly one of the subschemas. If you have two or more subschemas valid, then an error should be thrown.
The OneOf Validator iterates through the validators for each choice in OneOf and validates.
When it encounters the second "valid" schema element, it returns a validation error:
{ "error" : {"statusCode":400,"code":"ERR11004","message":"VALIDATOR_SCHEMA","description":"Schema Validation Error - $.search: should be valid to one and only one of the schemas ","severity":"ERROR"} }
In this case, the matching element was the 8th out of 11th, however the code analyzed them one by one and failed in the second one already, where only the 8th is a true match.
The issue is in the PropertiesValidator, where it tries to find an entry by a key and does not find it.
It treats the "not found" as normal, instead of issuing an error and letting the OneOf Validator handle it gracefully (in this ignore it)
...
JsonNode propertyNode = node.get(entry.getKey());
...
Proposed resolution includes the issuance of an error when property node does not match and letting the caller in the recursive chain handle it.
It must be properly validated and ascertained that there are no side-effects.
It is a showstopper for a number of APIs at a client site.
The text was updated successfully, but these errors were encountered: