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
Wrong formating for custom struct names #1150
Comments
This is an open-source project. Feel free to contribute with a fix and I will be more than happy to assist you with a Code Review. |
MattKetmo
added a commit
to MattKetmo/swag
that referenced
this issue
Jun 30, 2022
Fix issue swaggo#1150 To summarize of the issue, running `swag fmt` will set (at least) 2 spaces between the attribute tag and the rest of the comment. For instance: ``` type Example struct { Foobar string } // @name Example ``` However the doc generation doesn't interpret this correctly for struct (it completly ignore it). So there are 2 solutions: - fix the indent (which is feel more natural) - fix the doc generation to correctly parse 2 spaces This commit is fixing the indent part. Basically I just set the padding=1 on `tabwriter`. The cons is that it will also impacts all other godocs. For instance (taken from the readme): ``` // @title Swagger Example API // @Version 1.0 // @description This is a sample server celler server. // @termsofservice http://swagger.io/terms/ ```
MattKetmo
added a commit
to MattKetmo/swag
that referenced
this issue
Jun 30, 2022
To summarize the issue, running `swag fmt` will set (at least) 2 spaces between the attribute tag and the rest of the comment. But this is a problem for struct with single comment: ```diff type Example struct { Foobar string -} // @name Example +} // @name Example ``` Indeed the doc generation doesn't interpret this correctly for struct (it completely ignore it). So there are 2 solutions: - fix the indent (which is feel more natural) - fix the doc generation to correctly parse 2 spaces This commit is fixing the indent part. Basically I just set the padding=1 on `tabwriter`. The cons is that it will also impacts all other godocs. For instance (taken from the readme): ```diff -// @title Swagger Example API -// @Version 1.0 -// @description This is a sample server celler server. -// @termsofservice http://swagger.io/terms/ +// @title Swagger Example API +// @Version 1.0 +// @description This is a sample server celler server. +// @termsofservice http://swagger.io/terms/ ```
MattKetmo
added a commit
to MattKetmo/swag
that referenced
this issue
Jun 30, 2022
To summarize the issue, running `swag fmt` will set (at least) 2 spaces between the attribute tag and the rest of the comment. But this is a problem for struct with single comment: ```diff type Example struct { Foobar string -} // @name Example +} // @name Example ``` Indeed the doc generation doesn't interpret this correctly for struct (it completely ignore it). So there are 2 solutions: - fix the indent (which is feel more natural) - fix the doc generation to correctly parse 2 spaces This commit is fixing the indent part. Basically I just set the padding=1 on `tabwriter`. The cons is that it will also impacts all other godocs. For instance (taken from the readme): ```diff -// @title Swagger Example API -// @Version 1.0 -// @description This is a sample server celler server. -// @termsofservice http://swagger.io/terms/ +// @title Swagger Example API +// @Version 1.0 +// @description This is a sample server celler server. +// @termsofservice http://swagger.io/terms/ ```
ubogdan
pushed a commit
that referenced
this issue
Jun 30, 2022
To summarize the issue, running `swag fmt` will set (at least) 2 spaces between the attribute tag and the rest of the comment. But this is a problem for struct with single comment: ```diff type Example struct { Foobar string -} // @name Example +} // @name Example ``` Indeed the doc generation doesn't interpret this correctly for struct (it completely ignore it). So there are 2 solutions: - fix the indent (which is feel more natural) - fix the doc generation to correctly parse 2 spaces This commit is fixing the indent part. Basically I just set the padding=1 on `tabwriter`. The cons is that it will also impacts all other godocs. For instance (taken from the readme): ```diff -// @title Swagger Example API -// @Version 1.0 -// @description This is a sample server celler server. -// @termsofservice http://swagger.io/terms/ +// @title Swagger Example API +// @Version 1.0 +// @description This is a sample server celler server. +// @termsofservice http://swagger.io/terms/ ```
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wrong formating for custom struct names
When run
swag fmt
2 spaces appear between@name
and the name instead of one and the name is parsed as an empty stringTo Reproduce
Steps to reproduce the behavior:
swag fmt -g filename.go
@name User
instead of@name User
in your codeswag init -g path/to/mani.go
Expected behavior
Correct type name, "User"
Screenshots

Swag version
Go version
Desktop:
The text was updated successfully, but these errors were encountered: