gofiber / swagger

🧬 fiber middleware to automatically generate RESTful API documentation with Swagger

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Bearer Authentication to Swagger Documentation

kazimovzaman2 opened this issue · 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",
}))
//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