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

OneOf validator is not throwing valid error if any of the child nodes has invalid schemas. #354

Closed
prubdeploy opened this issue Nov 24, 2020 · 6 comments

Comments

@prubdeploy
Copy link
Contributor

No description provided.

@stevehu
Copy link
Contributor

stevehu commented Nov 24, 2020

@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?

@jiachen1120
Copy link
Contributor

@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?

@stevehu
Copy link
Contributor

stevehu commented Nov 25, 2020

@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.

@prubdeploy
Copy link
Contributor Author

prubdeploy commented Nov 25, 2020

Hi @stevehu ,
I am unable to push my changes for the Issue #354 . Could you please grant me the necessary permissions.
FYI,
@jiachen1120 @miklish

@stevehu
Copy link
Contributor

stevehu commented Nov 25, 2020

@prubdeploy I have sent you an invite. Please create a branch to push your changes. Thanks.

@stevehu
Copy link
Contributor

stevehu commented Dec 30, 2020

This has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants