I am quite new to Golang and have been trying to use go-swagger to generate REST API documents. I have been following
articles for implementing this. I used Gorrila Mux as a router in my application. But after annotating the code, when I try to generate the swagger.json file, I get a weird error showing something like this
cannot use &authModel (value of type *model.AuthLoginModel) as *model.AuthLoginModel value in argument to (service.AuthService literal).ValidateCredential
BackGround: I have created a struct called AuthLoginModel and put the annotation
//swagger:model
on top of the defined struct(which is in a different models package). In my file I am creating a variable of the type AuthLoginModel and and using it in my function called ValidateCredential as shown below.
var authLM model.AuthLoginModel
{populate authLM}
validateCredentials(&authLM, {other parameters})
My annotation on for my main.go is as shown below.
// Package rest HTTP API.
//
// Schemes: http
// Host: localhost
// BasePath: /api
// Version: 0.0.1
// Consumes:
// - application/json
// Produces:
// - application/json
// swagger:meta
package main
And my annotation for the handler is as shown below
// swagger:operation POST /token/generate Token_generate
// Generates a token
//
// ---
// summary: Token Generation
// parameters:
// - in: body
// required: true
// schema:
// $ref: "#/token/generate"
// responses:
// responses:
// '200':
// description: successful operation
// schema:
// $ref: "#../../model/AuthLoginModel"
//