-
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
Default values #98
Comments
My init is this, btw:
|
It is supported, but you need custom ajv configuration for that. See https://github.com/Zooz/express-ajv-swagger-validation/blob/master/test/express/test-simple-server-with-coercion.js for an example. |
Thanks kibertoad - looks like I'm doing the right thing by passing on useDefaults to ajv, but still no joy. An example of a not used default from my schema is:
express-openapi-validator also uses ajv and inserts this and other defaults ok, but does not support discriminators. |
Ok. Done some testing. If I modify the schema so the Pet type is this:
And create an extra test in test/express/middleware-test.js
The "tag" value shoud be defaulted to 'Taggy McTagface', but it isn't, instead we get: As an aside, as 'tag' is now required, this test should fail with a 400. |
@catadch thanks for reporting the issue. First of all this is a bug, as we should pass We'll need to investigate this further. |
Any news on this topic? 😄 |
I need a validator that inserts default values in the request body AND honors with discriminators, yours does the latter, but not the former. I have found others that are the other way around.
Am I doing something wrong, or is it a know issue that this package does not insert default values from the schema?
The text was updated successfully, but these errors were encountered: