Option to strip out unused parameters
This may already be included somewhere, but it would be awesome if there was an option to strip out parameters that aren't in the docs. For example:
If a query parameter age is defined, but ?age=30&foo=bar is passed, I would like req.query to only contain age.
I'm not sure which underlying express-openapi-* module would contain this, or perhaps it would be a new one.
I like the idea a lot. It would probably make sense as middelware in this project for now. If you'd like to add a PR feel free.
Cool, I'll take a look :) When I was attempting to build a swagger type api "thing" once upon a time, I relied on ajv to do my parsing and stripping and stuff. Might need to do something like that for body. Any favorite json-schema libraries?
Any favorite json-schema libraries?
Checkout the dependencies for this project. Ideally we can leverage one of those.
Cool, I'll check it out
@ksmithut how are things going? Is this still an issue?
I haven't had time to look into get... Got back into the swing at work and such. Feel free to close this out.
I like the idea as an enhancement (labeled this as such). If you have time to add the functionality feel free!
The ajv option "removeAdditional: true" does this when the schema has "additionalProperties: false". There are other options for removeAdditional
@buzzware sounds like you can control this via the schema then? would updating the README suffice?
I'm dealing with same/similar problem, need to remove additional data without throwing errors.
- when i set
"additionalProperties: false"into schema validator throw errors - when i add to
AjvconfigremoveAdditional: trueit removes additional data and not throws errors
Very helpful is this test https://github.com/ajv-validator/ajv/blob/ba752505cf53a136eda1c4f4b81bf9e697a42dc2/spec/options/removeAdditional.spec.ts#L27
Would be nice to have ajv options configurable for openapi-request-validator, or at least just this one removeAdditional.
(using only component openapi-request-validator)
UPDATE: i want to remove additional data from body.