swaggo / swag

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

Flags to parse internal and dependency package #1894

Closed bytesByHarsh closed 1 month ago

bytesByHarsh commented 1 month ago

Remove cannot find type definition error

package model

type PaginatedListResp[T any] struct {
    Data         []T  `json:"data"`
    TotalCount   int  `json:"total_count"`
    HasMore      bool `json:"has_more"`
    Page         int  `json:"page"`
    ItemsPerPage int  `json:"items_per_page"`
}

type User struct {
    ID          uuid.UUID `json:"id"`
    Name        string    `json:"name"`
    PhoneNum    string    `json:"phone_number"`
    Email       string    `json:"email"`
    Username    string    `json:"username"`
}
package api
.
.
.
//  @Success    200 {object}    models.PaginatedListResp[models.User]

Additional context If the model is part of an external dependency or internal package then flags mentioned in the PR can be used but were not mentioned in the generics section.

In some cases simple import _ github.com/xxx/models also works but if it does not then adding either --parseDependency or --parseInternal helps in solving the issue based on requirement.

ubogdan commented 1 month ago

@bytesByHarsh Thanks for your contribution!