Skip to content

Rejecting unknown query parameters should be optional #133

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

Closed
rgcunha opened this issue Nov 21, 2019 · 5 comments
Closed

Rejecting unknown query parameters should be optional #133

rgcunha opened this issue Nov 21, 2019 · 5 comments
Labels
enhancement New feature or request

Comments

@rgcunha
Copy link

rgcunha commented Nov 21, 2019

Hi,

Would it be possible to make unknown query parameter validation optional?
https://github.com/cdimascio/express-openapi-validator/blob/master/src/middlewares/openapi.request.validator.ts#L109

Problem:
We have an API for a react-native app that needs to support multiple client versions. Some of the legacy versions still send query params which are no longer specified in the latest API spec as such we need to bypass the unknown query param validation.

Unfortunately there doesn't seem to be a way to make this validation optional atm.

Thanks

@cdimascio
Copy link
Owner

cdimascio commented Nov 21, 2019

@rgcunha yes. this is a good idea. we'll plan to provide this option to the request validator

@cdimascio cdimascio added the enhancement New feature or request label Nov 21, 2019
cdimascio added a commit that referenced this issue Nov 22, 2019
Rejecting unknown query parameters should be optional #133
@cdimascio
Copy link
Owner

hi @rgcunha, give 2.16.0 a try.
You can set

 validateRequests: {
   allowUnknownQueryParameters: true
 }

to allow unknown query params to pass validation

@rgcunha
Copy link
Author

rgcunha commented Nov 23, 2019

tested. works as expected. thanks @cdimascio 👌

@WilliamStewart
Copy link

Any way of doing this for a specific endpoint instead of globally?

@cdimascio
Copy link
Owner

cdimascio commented Feb 27, 2020

@WilliamStewart Currently, there is not. It's something to consider. Feel free to open an issue and perhaps a description of the use case.
Without knowledge of your use case, I'd argue that it's better to keep this behavior consistent (choose one or the other for the entirety of the API) in order to alleviate confusion amongst the APIs users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants