-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
improve: added parameter definition to route openapi #518
base: master
Are you sure you want to change the base?
Conversation
@juneidysoo thanks for the PR can you describe the use case here in more detail? |
Hi @cdimascio , I am using the parameters schema to extract all parameters from It's just an easier way to make my API compliant to the OpenAPI spec by only taking parameters defined in the spec. |
assuming im understanding correctly, a better approach may be to use |
Let's say I have a schema like:
Sometimes there are extra headers sent to server that I don't mind being sent (e.g. I understand that both |
I'll try to fix the test once we agreed whether or not this is a good idea. |
@juneidysoo thanks for the explanation. this makes sense. ideally, we should handle this within the validator. this way developers do not have to worry about it. i believe this can be handled similarly to query params. it will likely also require a new option, e.g. |
I believe that would cause more issues. Because often case people would have reverse proxy which would generally adds extra headers (e.g. In my opinion, those extra headers are fine, and I don't want the validation to fail. Sometimes I do want them, but most of the time they are ignored. Hence the need for parameters list. |
Although alternatively, I could do something like |
Hi @cdimascio Following up on what you think of what I have said. |
@juneidysoo thanks for the details and for continuing to think about this based on your comment, allowing additional headers (the default behavior) is definitely what you want. your proxy example is a good one. i see that you'd like more of the validator internals exposed so that you can do this post-filtering, but i'm not yet understanding the benefit of that filtering. it seems that the request is validated correctly and allows those additional headers e.g. from a proxy given that it's okay for those headers to pass through, i'd like to get a better idea of why its necessary to perform additional post-filtering? |
What I am trying to do is to perform parameter injection based on the parameter declared in openapi spec. So that the underlying function that handles the route doesn't need to know where or how to get the parameters. |
let's try to go with your alternative i.e. the |
Hi there,
I've added slight modification to dereference parameters so that my route handler can use that to extract all parameters from
req
object.