swagger icon indicating copy to clipboard operation
swagger copied to clipboard

Add Bearer Authentication to Swagger Documentation

Open kazimovzaman2 opened this issue 1 year ago • 2 comments

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",
}))

kazimovzaman2 avatar Feb 11 '24 06:02 kazimovzaman2

//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

BrianIto avatar Apr 27 '24 19:04 BrianIto