-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Use form tags when available #1422
Conversation
Why do we want to introduce such a fallback? @sdghchj What do you think about this change? |
The swagger file that's currently generated is incorrect. For example, I have a struct of the form:
which represents the GET input parameters for my handler. By including the change, developers who explicitly set the More generally, the Here's an example from the gin documentation of how the |
What if a struct is shared by two routers, one use it as form request model, the other use it as response model? |
Is there a better way to support this? Such as parsing form tag into extensions with a special extension name and pick it when parsing request according to |
Yes. An optimal solution might be to select the The only need for that enhancement is specificity when the tags are not consistent. The current behavior on master is wrong for query parameters. It fails to generate correct parameter names for My change is an improvement in that JSON still takes priority when no other tag is used OR when the Without this change, how is one supposed to define an OPENAPI definition for query parameters using a struct? I am not clear why one would put a |
@pconstantinou As @sdghchj suggested, the struct can be shared between "accept" and "query", but after it gets parsed which models should we store into documentation the one handling JSON tags, the one with form tags, or the one with query tags? |
Any updates on this? I'm also having some trouble using the uppercase acronym pattern naming in Go and requesting the camelcase style in the API with the |
Anyway, this is a temporary solution. |
Describe the PR
swaggo doesn't look at the
form
tag on structs to determine field names, only thejson
tag. This update sets the field name in the swagger files to theform
tag if it exists. This will match what gin binds to.Relation issue
This issue was also raised here:
#1411
Additional context
Add any other context about the problem here.