swag
swag copied to clipboard
Error cannot find type definition: decimal.NullDecimal
Describe the bug I create a struct with decimal.NullDecimal inside then when generate swaggo got this error Error cannot find type definition: decimal.NullDecimal
To Reproduce Steps to reproduce the behavior:
- Create a struct with decimal.NullDecimal field
- Swag init
Expected behavior Generate normally like decimal.Decimal
Your swag version swag version v1.8.10
Your go version go version go1.20 linux/amd64
Desktop (please complete the following information):
- OS: Windows 10
- Version: 21H2 (OS Build 19044.2965)
If the type is internal you have to add the flag --parseInternal, if its from a dependency use --parseDependency
swag init --parseDependency --parseInternal
Hi all!)
I have the same issue with:
swag init --parseInternal --parseDepth 2 -g path/to/my/main.go
Output:
cannot find type definition: sql.NullTime
Maybe there are other solutions to resolve this issue?
stanlyzoolo
I have another solution, make the .swaggo file among with your go.mod Content inside .swaggo will be
replace JsonNullBool boolean
replace JsonNullNumber integer
replace JsonNullNumberStr string
replace decimal.NullDecimal number
maybe your case will be
replace sql.NullTime string
Thanks for an advice)
I found a the better solution by adding swaggertype:"string" tag for selected sql.NullTime type.
Take a look here --> https://github.com/swaggo/swag#use-swaggertype-tag-to-supported-custom-type
It works well for me :+1: