-
Notifications
You must be signed in to change notification settings - Fork 324
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
OneOf validator is not throwing valid error if any of the child nodes has invalid schemas. #354
Comments
@prubdeploy anyOf, oneOf and allOf are very complicated in the validator and there must be some scenarios that are not captured yet. Could you please submit a unit test case to show us the exact scenario so that we can have the same base to discuss? |
@stevehu Hi Steve. A example schema for this is: requestBody:
required: true
content:
application/json:
schema:
required:
- pet
properties:
oneOf:
- $ref: '#/components/schema/dog'
- $ref: '#/components/schema/cat' If request body not match with both dog and cat, there will be two error messages within the validation result. However, only the first one will be added to reponse status (schemaValidator.doValidate only use the first validationMessage as return status). Therefore, when user sent a request which doesn't match with both dog and cat, he may get a error message said his request doesn't match with dog. However, I think a more proper response at this momoent may be "not match with pet.oneOf". What do you think? |
@jiachen1120 Thanks for the example. Yes. Your error message makes sense. I have marked this issue as a bug and we need to get it fixed. |
Hi @stevehu , |
@prubdeploy I have sent you an invite. Please create a branch to push your changes. Thanks. |
This has been merged. |
No description provided.
The text was updated successfully, but these errors were encountered: