You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
swagger version: 48f1315
go version: 1.14
OS: Linux
Testing this for generating swagger specs... I have this function that returns an HTTP handler:
// Login logs in a user
func (s *Server) Login() http.HandlerFunc {
type loginRequest struct {
Username string `json:"username"`
Password string `json:"password"`
}
type loginResponse struct {
Token string `json:"token"`
}
// This returns the JWT token used for Authorization: Bearer header
// swagger:parameters login
type SwaggerRequest struct {
// The username and password payload
// in: body
// requred: true
Payload *loginRequest
}
// Login Success
// swagger:response loginResponse
type SwaggerResponse struct {
// The JWT token
// in: body
Payload *loginResponse
}
// swagger:route POST /api/login AUTH login
// Login to system
// responses:
// 200: loginResponse "Success"
return func(w http.ResponseWriter, r *http.Request) {
// do login stuff
}
}
When I try to generate the spec it shows: unable to find package and source file for: github.com/reponame/package.passwordRequest
If I move the loginRequest and loginResponse structs outside of the Login() function it works. Is there any way to fix it to be able to see those struct in that scope? Is there a better way I should be defining this login function?
The text was updated successfully, but these errors were encountered:
Environment
swagger version: 48f1315
go version: 1.14
OS: Linux
Testing this for generating swagger specs... I have this function that returns an HTTP handler:
When I try to generate the spec it shows:
unable to find package and source file for: github.com/reponame/package.passwordRequest
If I move the
loginRequest
andloginResponse
structs outside of the Login() function it works. Is there any way to fix it to be able to see those struct in that scope? Is there a better way I should be defining this login function?The text was updated successfully, but these errors were encountered: