swaggo / swag

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

[Q&A] Regarding settings of structs with the same name in the same package #1899

Closed haradayoshitsugucz closed 1 month ago

haradayoshitsugucz commented 1 month ago

In my repository, there are structs with the same name in different directories within the same package as shown below.

github.com/my-org/my-repo/model/account.go

package model

type Account struct {
    ID string `json:"id"`
    Name string `json:"name"`
}

github.com/my-org/my-repo/model/v2/account.go

package model

type Account struct {
    ID string `json:"id"`
    Name string `json:"name"`
    Email string `json:"email"`
}

In that case, if you specify the response as shown below, a ParseComment error will occur.

// @Success 200 {object} model.Account

Is there any solution?