-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
crash on version 1.8.5 when running 'swag init --parseDependency' #1319
Comments
Me too |
1 similar comment
Me too |
use 1.8.4 instead, that's current stable version. |
v1.8.4 doesn't work for me. panic: runtime error: invalid memory address or nil pointer dereference goroutine 1 [running]: |
Are you sure? Your error message says that you are still using v1.8.5: You can use v1.8.4 in your go.mod file |
try the master branch of swaggo. You can install it with the following command. go install github.com/swaggo/swag/cmd/swag@master |
I am still getting the same error on latest master @FabianMartin
type Pagination struct {
Index int `json:"index"`
Size int `json:"size"`
Total int `json:"total"`
}
type PaginatedResponse[T any] struct {
Data []T `json:"data"`
Pagination Pagination `json:"pagination"`
}
type MyTemplateType struct {
ID int `json:"id"`
Name string `json:"name"`
} Swag annotations:
Swaggo version:My project has: |
@ghoshabhi Can you provide a test repository? |
i have an example now @FabianMartin https:/ghoshabhi/go-swaggo-test |
- Generic detection moved to own method - prepend pkg path if not provided refs swaggo#1319
@ghoshabhi PR #1328 contains a fix for your issue. Currently, the generics are only detected if the definition contains the pkg name // @Success 200 {object} PaginatedResponse[ResponseItem] to // @Success 200 {object} api.PaginatedResponse[api.ResponseItem] it should find the definition. After merging the PR, swaggo will also detect generics without pkg name. |
thanks @FabianMartin ! let me try moving the definitions to a separate pkg. No rush, but do you have a rough eta on when v1.8.6 will be released ? |
The warning contains the solution to your issue. It cannot determine the package name. Change your call to the following, and it should work. swag init --parseDependency --parseInternal --dir ./cmd/api |
@ubogdan releases new versions and in #1310 (comment) he wrote that a new version will be released soon. |
aha! yeah that worked. Weird, according to docs |
- Generic detection moved to own method - prepend pkg path if not provided refs #1319
Same here ... happens with ([email protected]): type MyTest struct { Running *swag init .... * (without --parseDependency) leads to following error: ".... :cannot find type definition: xml.Name" Whereas swag init --parseDependency .... leads to the described error *github.com/swaggo/swag.(PackagesDefinitions).parseFunctionScopedTypesFromFile(0x1400000e858, 0x14001732880, {0x1400037d8f0, 0x15}, 0x140026b3ad0) Switching back to [email protected] does not show the --parseDependency error. |
1.8.6 contains a fix for this. Current Version is 1.8.7. Please update and test again. |
Thx for fast response - updated to [email protected] *swag init --parseDependency .... works correctly |
hi, i found a bug content as follows
swag init --parseDependency
2022/09/06 21:11:42 Generate swagger docs....
2022/09/06 21:11:42 Generate general API Info, search dir:./
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x2 addr=0x8 pc=0x102814d20]
goroutine 1 [running]:
github.com/swaggo/swag.(*PackagesDefinitions).parseFunctionScopedTypesFromFile(0x1400000e858, 0x14001732880, {0x1400037d8f0, 0x15}, 0x140026b3ad0)
go/pkg/mod/github.com/swaggo/[email protected]/packages.go:168 +0x90
github.com/swaggo/swag.(*PackagesDefinitions).ParseTypes(0x1400000e858)
go/pkg/mod/github.com/swaggo/[email protected]/packages.go:110 +0xa0
github.com/swaggo/swag.(*Parser).ParseAPIMultiSearchDir(0x140001b42a0, {0x140001da0b0?, 0x1?, 0x0?}, {0x10283f25a?, 0x7?}, 0x64)
go/pkg/mod/github.com/swaggo/[email protected]/parser.go:362 +0x29c
github.com/swaggo/swag/gen.(*Gen).Build(0x140001ad980, 0x140001aeea0)
go/pkg/mod/github.com/swaggo/[email protected]/gen/gen.go:177 +0x4a0
main.initAction(0x140001418c0?)
go/pkg/mod/github.com/swaggo/[email protected]/cmd/swag/main.go:151 +0x654
github.com/urfave/cli/v2.(*Command).Run(0x14000000fc0, 0x140001c6340)
go/pkg/mod/github.com/urfave/cli/[email protected]/command.go:163 +0x4fc
github.com/urfave/cli/v2.(*App).RunContext(0x1400011d6c0, {0x1029f5630?, 0x140000300b8}, {0x140000201b0, 0x3, 0x3})
go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:313 +0x860
github.com/urfave/cli/v2.(*App).Run(...)
go/pkg/mod/github.com/urfave/cli/[email protected]/app.go:224
main.main()
go/pkg/mod/github.com/swaggo/[email protected]/cmd/swag/main.go:221 +0x65c
The text was updated successfully, but these errors were encountered: