Setting up go-swagger in an existing project to generate API docs

I have an existing project that needs a UI for the API. I want to use go swagger but I am completely confused
I want to set it up so I add annotations in the code and then run the command swagger generate spec and it would generate the spec
However whenever I run it, it prints {"swagger":"2.0","paths":{},"definitions":{}}
My project structure is as follows


In main.go I have this annotation

//go:generate swagger generate spec
package main

In router above one of my handlers I have this annotation

// swagger:route GET /profile
// Gets profile of user
//     Produces:
//     - application/json
//     - application/x-protobuf
//     Schemes: http, https, ws, wss
//     Security:
//       api_key:
//       oauth: read, write
//     Responses:
//       default: genericError
//       200: someResponse
//       422: validationError
r.GET("/profile", profileHandler

I’ve been stuck trying to set up an api generator for a while. Any help is much appreciated. If you have experience setting it up, please let me know how you did it

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.