Swag: How to set the header on swagger?

Created on 7 Jun 2018  路  3Comments  路  Source: swaggo/swag

I have a question.

My API need token authentication.
How should I set header key "Authorization" on swagger doc?

my code:
// @Description api
// @Accept json
// @Produce json
// @Content-Type application/json
// @Param sendBody body apimodel.ExamplePost true "body"
// @Success 200 {string} apimodel.Response "ok"
// @Failure 400 {object} apimodel.Response "Bad Request"
// @Router /v1/example/testpost [post]

question

Most helpful comment

// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
func main() {
}

// @Security ApiKeyAuth
// @Router /api/v1/list  [get]
func list() {
}

All 3 comments

// @securityDefinitions.apikey ApiKeyAuth
// @in header
// @name Authorization
func main() {
}

// @Security ApiKeyAuth
// @Router /api/v1/list  [get]
func list() {
}

Does this not work with OAuth2Implicit? My header is not being sent after authentication @easonlin404

Was this page helpful?
0 / 5 - 0 ratings