gofiber / swagger

🧬 fiber middleware to automatically generate RESTful API documentation with Swagger
MIT License
416 stars 31 forks source link

Add Bearer Authentication to Swagger Documentation #80

Open kazimovzaman2 opened 8 months ago

kazimovzaman2 commented 8 months ago

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",
}))
BrianIto commented 6 months ago
//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
xl495 commented 3 weeks ago
//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

But it seems like this method doesn't work for adding the token in the format Bearer xxx, right?