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

No operations defined in spec! #64

Open
lesnoyleshyi opened this issue Apr 18, 2022 · 0 comments
Open

No operations defined in spec! #64

lesnoyleshyi opened this issue Apr 18, 2022 · 0 comments

Comments

@lesnoyleshyi
Copy link

lesnoyleshyi commented Apr 18, 2022

Hi! I can't generate documentation to my project.
My project's structure looks like that:

- cmd
   - api
      main.go
- docs
   docs.go
   swagger.json
   swagger.yaml
- internal
   - domain
   - handlers
      users.go
      ...

I have the next annotation in /cmd/api/main.go:

// @title         API for my application
// @version	  0.1
// @description   It's made for testing purposes only

// @host          localhost:8080
// @BasePAth      /

func main() { ... }

And this is in /internal/handlers/users.go:

//	Returns full user info godoc
//  @Description Returns lists
//  @Summary Returns full user info
//  @Tags Lists
//  @Accept json
//  @Produce json
//  @Success default {object} domain.Response
//  @Failure default {object} domain.Response
//  @Router /users/full [get]

func (h userHandler) getFullUserInfo(w http.ResponseWriter, r *http.Request) { ... }

I'm running
swag init -g cmd/api/main.go --parseDependency --parseInternal
from the root directory of the project.
I'm getting

> Generate swagger docs....
> Generate general API Info, search dir:./
> warning: failed to get package name in dir: ./, error: execute go list command, exit status 1, stdout:, stderr:no Go files in /Users/stycho/GolandProjects/my_life
> create docs.go at  docs/docs.go
> create swagger.json at  docs/swagger.json
> create swagger.yaml at  docs/swagger.yaml

and "No operations defined in spec!" when I enter http://localhost:8080/swagger/index.html .

I've tried different --parseDepth values, no --parseDependency or --parseInternal . I've also tried to make blank import in /internal/handlers/users.go - all this doesn't help.

I tried to google the solution, but haven't find anything. I can't understand what I'm doing wrong. Could you help me please?

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