Swagger
Swagger middleware for Fiber. The middleware handles Swagger UI.
Note: Requires Go 1.18 and above
Install
go get -u github.com/gofiber/fiber/v2
go get -u github.com/gofiber/contrib/swagger
Signatures
func New(config ...swagger.Config) fiber.Handler
Config
Property | Type | Description | Default |
---|---|---|---|
BasePath | string | BasePath is the base path for the configuration file. | "" |
FilePath | string | FilePath is the file path to the configuration file. | "" |
Examples
Import the middleware package that is part of the Fiber web framework
import (
"github.com/gofiber/fiber/v2"
"github.com/gofiber/contrib/swagger"
)
Then create a Fiber app with app := fiber.New().
After you initiate your Fiber app, you can use the following possibilities:
Default Config
app.Use(swagger.New(cfg))
Custom Config
cfg := swagger.Config{
BasePath: "/", //swagger ui base path
FilePath: "./docs/swagger.json",
}
app.Use(swagger.New(cfg))