-
Notifications
You must be signed in to change notification settings - Fork 50
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
Response validation does not work at all #43
Comments
Hi, I experienced the same issue and I investigated it a bit further. Short answer:Use Long answer:Response validation is hooked on Current implementation of the Pet example is using
and utils.writeJson(res, response) calls response.end(payload) :
That means hooked res.json() is never called so validation is not executed.
Also Express suggest to use Keep in mind, that validation will work only with JSON response. I also tested, that it is possible to enable response validation which will remove all fields not mentioned in openAPI schema:
|
to my previous answer:
There is a problem with response validation when removeAdditional: 'all' option is used in this case:
removeAdditional option is propagated to ajv which describes the problem here: Solution could be to use |
Hi.
I am trying to validate my API responses, but no matter what is send as a response, there is no indication of an error.
Steps to reproduce:
git clone [email protected]:bug-hunters/oas3-tools.git
cd oas3-tools
npm install
npm run build
cd examples/petstore
npm install
npm start
curl localhost:8080/pet/0 -H api_key:test
I would expect to receive an error in this case.
Using the
express-openapi-validator
directly instead works:The text was updated successfully, but these errors were encountered: