Skip to content
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

fix: fmt issue with struct #1248

Merged
merged 1 commit into from Jun 30, 2022
Merged

Commits on Jun 30, 2022

  1. Fix issue swaggo#1150

    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 committed Jun 30, 2022
    Copy the full SHA
    1524e3a View commit details
    Browse the repository at this point in the history