-
Notifications
You must be signed in to change notification settings - Fork 277
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 cannot generate docs when main go is located in directory #73
Comments
You can target swag cli to files that you need.
it will execute swag on your And what do you mean by "doesn't include ./internal ..." |
very helpful~~ |
Yeah this still doesnt work for me as there is still the error when using the above parameters:
|
So I worked around it by doing the following: My file tree looks something like this.
I run the following command in the project root directory:
So there are few things to note here which I thought were really weird. 1.) As you can see the If you feel these should be separate issue please let me know and I will make them. |
Interestingly there is a way to do what
Takes a while (slower than go-swagger for whatever reason) but at least it generates everything I'd like. I really think the base readme should try to make the options for |
I have my gin code running in a subfolder of my Go project, it doesn't recognise it as well. Anyone an idea?
|
I am having the same issue. My repository structure is same as @kotyara85 and the moment I move my controllers out of |
--dir value, -d value Directories you want to parse,comma separated and general-info file must be in the first one (default: "./") Above is from the output of My project structure is as follows: ├── LICENSE
├── Makefile
├── README.md
├── cmd
│ └── server
│ └── main.go
├── deployments
│ ├── docker-compose.yml
│ └── prod.Dockerfile
├── docs
│ ├── docs.go
│ ├── swagger.json
│ └── swagger.yaml
├── go.mod
├── go.sum
├── internal
│ ├── router
│ │ ├── registry.go
│ │ └── router.go
... ...
├── pkg
... ...
└── testdata And I met the same error with Using |
I tried everything mentioned in the above comments and still doesn't work for me. |
This worked for me
/cmd/api/ is where my main.go file is located --pdl flag is describe in swag init -h:
basic the -pdl will try to find all your dependencies by the main.go file |
cmd/sireng/main.go i still can't get the api documentation handlers i have done swag init -g ../cmd/sireng/main.go -d ./internal -o ./docs but it only parses the main.go |
This is what worked for me,
I created a
and then I ran the following command:
Let me know if it works for you with a thumbs up. |
Tried all of the above - didn't help. |
We could try and debug. What are the errors you are getting? |
suppose your project name is CRUD and there are multiple directory named- cmd, internal, pkg go to the projects directory- And then run the command
This command traverse all the directory and create a documentation for all files. |
My project structure:
./
./cmd/main/main.go
./internal/xxxx
./pkg/xxxx
When I run swag init under root directory of the project it complains on absence of main.go.
When I run swag init under cmd/main/main.go it doesn't include ./internal or ./pkg directories
The text was updated successfully, but these errors were encountered: