-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Fix query coercion issue #571
base: master
Are you sure you want to change the base?
Fix query coercion issue #571
Conversation
@sabeslamidze I agree it'd be better to put this behind an option flag. 👍 Generally the less processing we make to the passed request object the better IMO. |
@anttiviljami don't you think if your schema says |
@@ -307,6 +307,10 @@ export class OpenAPIValidator<D extends Document = Document> { | |||
if (validate.errors) { | |||
result.errors.push(...validate.errors); | |||
} | |||
else { | |||
// set Ajv validator coerced query to request | |||
req.query = parameters.query |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Path params are needed to be copied too.
@sabeslamidze @anttiviljami @ziflex |
@ydayagi no, I meant that I want this library to parse numbers for me. I do not want to parse params in every handler. |
Fixed #554
Note that query parameters are coerced just fine by Ajv validators. But
parameters.query
is never assigned back to original request that is passed down to handlers.However, this might be not desirable behaviour by default. Maybe it is better to add additional option on OpenAPIBackend initialization to allow modifying data during validation like this:
Pls let me know what you think.