I just tried this out and discovered that an operationId is required for 
swagger:route:

// swagger:route GET /profile getProfile


tags go between the path and the operationId:

// swagger:route GET /profile tag1 tag2 getProfile


Hope this helps.

On Monday, October 17, 2016 at 7:01:52 AM UTC+2, SakShak wrote:
>
> I have an existing project that needs a UI for the API. I want to use go 
> swagger but I am completely confused
> https://github.com/go-swagger/go-swagger/tree/master/examples/todo-list
>
> 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
>
> project/ 
>   main.go
>   api/
>     router.go
>
> 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
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to