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

Validation for properties fails completly #470

Closed
ahoehn opened this issue Nov 26, 2020 · 2 comments
Closed

Validation for properties fails completly #470

ahoehn opened this issue Nov 26, 2020 · 2 comments

Comments

@ahoehn
Copy link

ahoehn commented Nov 26, 2020

Bug

  • Additional unspecified properties do not result in an request validation error.
  • wrong property types do not result in an request validation error

To Reproduce

  1. run 3-eov-operations example
  2. send a POST request to http://localhost:3000/v1/pets with the following body
    { "name": 556, "type": "cat", "tags": [ "purrfect" ], "test": "me" }

Actual behavior

  • Response contains the name property which was a number instead of string as a string value
  • not specified property "test" get's reflected
    Example:
    { "id": 7, "name": "556", "type": "cat", "tags": [ "purrfect" ], "test": "me" }

Expected behavior
A request validation error should send to the client for both validation errors

@cdimascio
Copy link
Owner

cdimascio commented Nov 26, 2020

Can your provide the validator version and a snippet of your spec?

cdimascio added a commit that referenced this issue Nov 27, 2020
@cdimascio
Copy link
Owner

cdimascio commented Nov 27, 2020

@ahoehn this test passes and seems to reflect your use case

https://github.com/cdimascio/express-openapi-validator/blob/master/test/additional.props.spec.ts#L33-L49

Note that the test has both an additionalProperty (which fails validation) and a number passed as a string (which also fails validation)

Make sure you are using additionalProperties: false to deny additional props. The type cases should work. Also ensure the spec is valid (can test using e.g. https://editor.swagger.io/)

Going to close this out. If the problem persists, please reopen with a canonical failing example. If you can post the failing example on github somewhere; all the better.

thanks!

ex1st pushed a commit to ex1st/express-openapi-validator that referenced this issue Dec 9, 2020
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

No branches or pull requests

2 participants