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

Swag fails to load type in external package. #1806

Open
chirino opened this issue May 6, 2024 · 2 comments
Open

Swag fails to load type in external package. #1806

chirino opened this issue May 6, 2024 · 2 comments

Comments

@chirino
Copy link

chirino commented May 6, 2024

Describe the bug
Swag fails to load type in external package.

To Reproduce

I created a super small project to illustrate the error:

git clone https://github.com/chirino/swag-bug-example/
cd swag-bug-example/main
swag init -g ./main.go -o .

Expected behavior
no errors should occur.

Screenshots

2024/05/06 17:05:49 Generate swagger docs....
2024/05/06 17:05:49 Generate general API Info, search dir:./
2024/05/06 17:05:49 Generating main.Foo
2024/05/06 17:05:49 Error parsing type definition 'main.Foo': field: cannot find type definition: lib.Bar
2024/05/06 17:05:49 ParseComment error in file /Users/chirino/sandbox/swag-bug-example/main/main.go :Foo: field: cannot find type definition: lib.Bar
exit status 1

Your swag version
v1.16.3

Your go version
go1.22.

@chirino chirino changed the title Swag fails to load type in external package where package path does not match the package name. Swag fails to load type in external package. May 6, 2024
@haminh0307
Copy link

swag init --parseDependency -g ./main.go -o .

You need to add option --parseDependency.

@rabarar
Copy link

rabarar commented May 13, 2024

I have the same problem - but it gives me an error saying the external package is missing when it's in both the go.mod and go.sum

running swag init --parseDependency produces:

missing go.sum entry for module providing package github.com/hcpd-solutions/pki; to add:
	go mod download github.com/hcpd-solutions/pki
missing go.sum entry for module providing package github.com/hcpd-solutions/pki; to add:
	go mod download github.com/hcpd-solutions/pki

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

3 participants