如何将JWT身份验证添加到swagger(go + echo + swaggo / swag)

I am using swaggo (https://github.com/swaggo/swag) to auto-create a working swagger specification for my API.

The swagger spec allows me to run all of my API endpoints and receive responses.

I then added JWT authentication to all of my endpoints. Now I'm unable to use the swagger spec to run any endpoints, as it always fails auth.

What annotations do I need to add to each endpoint, that will configure the Swagger spec to allow a JWT to be passed?

I've read the README at https://github.com/swaggo/swag and Google searched, to no avail.

Seems that these comments added to each endpoint did the trick...

// @Security ApiKeyAuth
// @param Authorization header string true "Authorization"

This comment was also added to our main.go file

// @securityDefinitions.apikey ApiKeyAuth

It's seems like the JWT middleware you added will be invoked before swaaggo/swag's hander. Can you post your routing settings?