express-openapi-validator icon indicating copy to clipboard operation
express-openapi-validator copied to clipboard

Response validation not working in 1-standard example

Open shousper opened this issue 3 years ago • 3 comments

Describe the bug Matching response status codes from the spec appear not to be working or too forgiving?

To Reproduce

  • Edit the api.yaml in 1-standard example, changing /ping response status code from 200 to any other status code.
  • Run the example.
  • curl the /v1/ping endpoint.
  • Observe it succeed.
  • curl the /spec endpoint to confirm edit if you like.

Actual behavior Success!

Expected behavior Validation error, response status code not defined.

Examples and context I tried this with master branch and v4.12.7 tag, same result.

shousper avatar Apr 14 '21 00:04 shousper

@shousper thanks for the issue.

note, if the code and spec are out of sync, you will get a validation error. for example, if the code is was modified to respond with a 201, but the spec still only defines a 200, then the validator will return a validation error.

closing this out for now. please reopen if the code and spec match and the error occurs. also, a code snippet will be super helpful. thanks!

cdimascio avatar Apr 18 '21 03:04 cdimascio

note, if the code and spec are out of sync, you will get a validation error.

This is exactly the problem. It does NOT produce a validation error when the code & spec are out of sync.

shousper avatar Apr 18 '21 04:04 shousper

ah gotcha. i misread. reopening

cdimascio avatar Apr 19 '21 01:04 cdimascio