swagger
swagger copied to clipboard
Add Bearer Authentication to Swagger Documentation
I need guidance on how to implement Bearer Authentication in the Swagger documentation for our Fiber middleware. Specifically, I'm unsure about what values to provide for the PreauthorizeApiKey field in the Swagger configuration. Any assistance on how to correctly configure this for Bearer Authentication would be greatly appreciated.
app.Get("/swagger/*", swagger.New(swagger.Config{
PreauthorizeApiKey: "Bearer",
}))
//main.go
// @Title "Your API Name"
// @SecurityDefinitions.apikey Bearer
This works fine for OAS 2.0.
On your code, you should name which routes (by placing it before the functions) should have this security param.
using
@Security Bearer