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

Swagger comments in Go files are not recursively parsed by Swaggo #274

Open
itoqsky opened this issue Jun 29, 2023 · 2 comments
Open

Swagger comments in Go files are not recursively parsed by Swaggo #274

itoqsky opened this issue Jun 29, 2023 · 2 comments

Comments

@itoqsky
Copy link

itoqsky commented Jun 29, 2023

Issue Description
Swaggo fails to recursively parse Swagger comments in Go files when using the swag init command with multiple directories and the --parseDependency and --parseInternal flags. Only the comments in the main file specified with the -g flag are parsed, while the comments in other files within the specified directories are not considered.

commands I have run:
swag init -d cmd/app/ -g main.go --parseDependency --parseInternal

swag init -d cmd/app/,internal/transport/http/v1 -g main.go --parseDependency --parseInternal

All the commands above produces the same result

Files that contain swaggo comments are internal/transport/http/v1/auth.go, internal/transport/http/v1/trip.go, and cmd/app/main.go
Structure
Screenshot 2023-06-27 at 16 15 50

Results
Screenshot 2023-06-27 at 16 15 24

Comments in one of the files other than cmd/app/main.go
Screenshot 2023-06-27 at 16 16 10

swag version
e.g. 1.8.12

go version
e.g. 1.20.2

OS
OSX

@fuddin95
Copy link
Contributor

fuddin95 commented Dec 9, 2023

Hi, were you able to find any solution

@scottmangiapane
Copy link

scottmangiapane commented Dec 30, 2023

I̶'̶m̶ ̶a̶l̶s̶o̶ ̶s̶t̶u̶c̶k̶ ̶o̶n̶ ̶t̶h̶i̶s̶.̶ ̶H̶a̶v̶e̶n̶'̶t̶ ̶f̶o̶u̶n̶d̶ ̶a̶ ̶s̶o̶l̶u̶t̶i̶o̶n̶ ̶y̶e̶t̶.̶.̶.̶ ̶I̶ ̶h̶a̶v̶e̶ ̶a̶ ̶s̶m̶a̶l̶l̶ ̶A̶P̶I̶ ̶t̶h̶o̶u̶g̶h̶ ̶s̶o̶ ̶I̶ ̶m̶i̶g̶h̶t̶ ̶j̶u̶s̶t̶ ̶h̶a̶n̶d̶ ̶w̶r̶i̶t̶e̶ ̶m̶y̶ ̶s̶p̶e̶c̶.̶

edit: just solved it. Posted in more detail here... Turns out you can't have a blank line between your annotations and the function declaration.

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