swag
swag copied to clipboard
Cannot find type definition with having import alias
Describe the bug Project structure. i have many small apps with own entity and uc, simply look like products -- domain ----- entity ------- products.go brands -- domain ----- entity ------- brands.go salepoint -- domain ----- entity ------- salepoint.go
products.go (bellow)
import "catalog/internal/core/apps/brands/domain"
salePoint "catalog/internal/core/apps/salepoint/domain"
type Product struct {
Brand *domain.Brand `json:"brand"`
SalePoint *salePoint.SalePoint `json:"sale_point"`
}
only one field (without alias) can be found during parsing.
in other layer i have
type SingleProductResponseV2 struct {
core.BaseResponse
Payload domain.Product `json:"payload"`
}
type ProductRequest struct {
domain.Product
ImageFile *multipart.FileHeader `form:"imageFile" json:"imageFile"`
}
// EditProductHandlerV2
// @Schemes
// @Accept mpfd
// @Description "изменение товара"
// @Param uuid path string true "product uuid"
// @Param payload formData ProductRequest true "payload product"
// @Success 200 {object} SingleProductResponseV2
// @Router /v2/products/{uuid} [put]
func (h *Handlers) EditProductHandlerV2(ctx *gin.Context) {}
Expected behavior generate api schema
Screenshots screenshot
Your swag version e.g. 1.8.4
Your go version e.g. 1.19.0
Desktop (please complete the following information):
- OS: linux x64
- Browser: [chrome, ]
- Version: [103.0.5060.114 ]
This is a well know issue that never got fixed. It's related to having the same package name too many times.
An untested workaround may be to alias all the imports for domain
packages with a unique alias.
I remember I fixed it one or two years ago