-
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
swaggo use structs field name instead of xml tag #427
Comments
This issue is not simple. What we should do when a struct has both tags (xml & json) ? |
Documentation is generated using Struct field name when json tags are missing. If you are going to accept json and xml payload on the same route based on http "Accept" header, I don't see a real reason to have different field name for each encoding. Please read the following section "Why JSON is Better Than XML" from this link https://www.w3schools.com/js/js_json_xml.asp and if you still consider XML should be a must , will see what we can do. |
Hi, XML wasn't my choice and I have not any chance to change it to JSON. Ok, double tags is not a real option. |
This apparently small change needs huge modifications in the parser, and I don't see them done very fast at least if someone have some time to do it for you. |
Ok, but I have a local patch to swag (for both tickets). |
We may change it to listen xml tag names if "@produce xml" is declared in controller annotation and json tag name is empty. |
Describe the bug
Hi. Swaggo doesn't use structs xml tag when it generate a swagger.yml/swagger.json
I have a struct like this:
and my swagger.yml is wrong and include this:
Expected behavior
Your swag version
1.5.1
Your go version
1.12.5
Desktop (please complete the following information):
I think you should check more than just
json
tag in the line parser.goThe text was updated successfully, but these errors were encountered: