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
URL Query params should be hinted as "form", not "json" #500
Comments
I've found exact place where it is generated https://github.com/deepmap/oapi-codegen/blob/master/pkg/codegen/schema.go#L447
|
Checked the code from master branch, auto-generated server reads query parameters as "form", so it's just annotations that are wrong representing them as "json" (annotations are not used by generated server). Created PR to fix this. Build passed green. |
The annotation on those fields isn't related to the parameter type in BindQueryParameter. There is something missing in the problem description. By changing the annotation to |
Oh, I see what's going on. We need both annotations, then, both Perhaps we add the |
@deepmap-marcinr I want to clarify, an auto-generated server works fine since it generates boilerplate code using BindQueryParameter and not using any annotations. But we are not using an auto-generated server and therefore the annotations are needed for BindQuery to work if we want to parse all parameters without writing much code. It was not clear at first why they are always nil. Both |
Very nice, thanks! |
This fixes deepmap#500, by adding a form tag to properties that come from request parameters and have a style of "form".
I've run into in issue that my parsed query params are always nil. It was resolved by manually changing query params hint from "json" to "form" in the generated types. The problem may be reproduced using petstore-expanded.yaml, generated code (not working):
code I expect to be generated (working):
Code I am using to parse query params:
The text was updated successfully, but these errors were encountered: