Skip to main content
Version: fiberi18n_v1.x.x

Swagger

Release Discord Test Security Linter

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

PropertyTypeDescriptionDefault
BasePathstringBasePath is the base path for the configuration file.""
FilePathstringFilePath 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))