swaggo / swag

Automatically generate RESTful API documentation with Swagger 2.0 for Go.
MIT License
10.58k stars 1.19k forks source link

Incorrect tab in swag fmt causes godoc display error #1801

Open skadiD opened 5 months ago

skadiD commented 5 months ago

Describe the bug In both GoLand and VSCode, a misalignment occurs in the display due to the use of a tab space between the @tag and the content. If a space is used for separation, the display appears normal.

Screenshots Now by swag fmt:

// ShowAccount godoc
//
//  @Summary        Show an account
//  @Description    get string by ID
//  @Tags           accounts
//  @Accept         json
//  @Produce        json
//  @Param          id  path        int true    "Account ID"
//  @Success        200 {object}    model.Account
//
//  @Failure        400 {object}    fiber.Ctx
//
//  @Failure        404 {object}    httputil.HTTPError
//  @Failure        500 {object}    httputil.HTTPError
//  @Router         /accounts/{id} [get]

image image

Expected behavior The content should align correctly (space replace tab)

// ShowAccount godoc
//
//  @Summary        Show an account
//  @Description    get string by ID
//  @Tags           accounts
//  @Accept         json
//  @Produce        json
//  @Param          id  path        int true    "Account ID"
//  @Success        200 {object}    model.Account
//
//  @Failure        400 {object}    fiber.Ctx
//
//  @Failure        404 {object}    httputil.HTTPError
//  @Failure        500 {object}    httputil.HTTPError
//  @Router         /accounts/{id} [get]

image

Your swag version 1.16.3

Your go version 1.22.0

Additional context This problem seems to be related specifically to the use of tab spaces for separation in the code. The display appears normal when a regular space is used instead.

1364 #1366