Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2: Type aliases cause nil dereference on --v3.1 flag #1930

Open
rasibn opened this issue Nov 25, 2024 · 0 comments
Open

v2: Type aliases cause nil dereference on --v3.1 flag #1930

rasibn opened this issue Nov 25, 2024 · 0 comments

Comments

@rasibn
Copy link

rasibn commented Nov 25, 2024

Describe the bug

type RequestParam struct {
	Price PriceType `form:"price" json:"price"`
}

type PriceType string

// @Param request  query    RequestParam false "Query Params"

Screenshots

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x2b8 pc=0x1013d9fe8]

goroutine 1 [running]:
github.com/swaggo/swag/v2.(*Parser).parseStructFieldV3(0x140002ba000, 0x140011de6e0, 0x14001244b80)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/parserv3.go:938 +0x3e8
github.com/swaggo/swag/v2.(*Parser).parseStructV3(0x140002ba000, 0x140011de6e0, 0x1400123e510)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/parserv3.go:817 +0xac
github.com/swaggo/swag/v2.(*Parser).parseTypeExprV3(0x140002ba000, 0x101492f09?, {0x1016b6a08?, 0x1400122b398?}, 0x80?)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/parserv3.go:740 +0x8bc
github.com/swaggo/swag/v2.(*Parser).ParseDefinitionV3(0x140002ba000, 0x14001ce9d10)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/parserv3.go:660 +0x3a4
github.com/swaggo/swag/v2.(*Parser).getTypeSchemaV3(0x140002ba000, {0x140001eb04d, 0x12}, 0x140011dedc0, 0x0)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/parserv3.go:611 +0xa7c
github.com/swaggo/swag/v2.(*OperationV3).ParseParamComment(0x14001e10c00, {0x140001eb030, 0x44}, 0x140011dedc0)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/operationv3.go:338 +0x92c
github.com/swaggo/swag/v2.(*OperationV3).ParseComment(0x14001e10c00, {0x140001eb020?, 0x1?}, 0x140011dedc0)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/operationv3.go:86 +0x180
github.com/swaggo/swag/v2.(*Parser).ParseRouterAPIInfoV3(0x140002ba000, 0x140012aacc0)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/parserv3.go:456 +0x188
github.com/swaggo/swag/v2.(*PackagesDefinitions).RangeFiles(0x14000296cf0, 0x14001c9f598)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/packages.go:107 +0x27c
github.com/swaggo/swag/v2.(*Parser).ParseAPIMultiSearchDir(0x140002ba000, {0x140002abf50, 0x1, 0x0?}, {0x16eedb4bd, 0x13}, 0x64)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/parser.go:422 +0x328
github.com/swaggo/swag/v2/gen.(*Gen).Build(0x140002969f0, 0x1400028ac80)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/gen/gen.go:219 +0x5c8
main.initAction(0x140002a2000)
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/cmd/swag/main.go:207 +0x74c
github.com/urfave/cli/v2.(*Command).Run(0x14000294160, 0x140002a2000, {0x140001bc720, 0x6, 0x6})
        /Users/rasib.nadeem/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:274 +0x5e0
github.com/urfave/cli/v2.(*Command).Run(0x14000294580, 0x140001bfe40, {0x140001c4000, 0x7, 0x7})
        /Users/rasib.nadeem/go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:267 +0x81c
github.com/urfave/cli/v2.(*App).RunContext(0x14000298000, {0x1016b7b98, 0x101ad3060}, {0x140001c4000, 0x7, 0x7})
        /Users/rasib.nadeem/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:332 +0x4f8
github.com/urfave/cli/v2.(*App).Run(...)
        /Users/rasib.nadeem/go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:309
main.main()
        /Users/rasib.nadeem/go/pkg/mod/github.com/swaggo/swag/[email protected]/cmd/swag/main.go:285 +0x4e0

Your swag version
2.0.0

Your go version
go version go1.23.2 darwin/arm64

Desktop:

  • OS: MacOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant