/fiber-swagger

fiber middleware to automatically generate RESTful API documentation with Swagger 2.0.

Primary LanguageGo

Description

This is a fork of fiber-swagger to add ModelsExpandDepth. For detailed instructions refer to the original README

Installation

Run the following command to install the package:

go get -u github.com/itgelo/fiber-swagger/v2

Canonical example:

package main

import (
    "github.com/gofiber/fiber/v2"
    "github.com/itgelo/fiber-swagger/v2"
    _ "github.com/itgelo/fiber-swagger/v2/example/docs" // docs is generated by Swag CLI, you have to import it.
)

// @title Fiber Example API
// @version 1.0
// @description This is a sample swagger for Fiber
// @termsOfService http://swagger.io/terms/
// @contact.name API Support
// @contact.email fiber@swagger.io
// @license.name Apache 2.0
// @license.url http://www.apache.org/licenses/LICENSE-2.0.html
// @host localhost:8080
// @BasePath /
func main() {
    app := fiber.New()

    app.Get("/swagger/*", swagger.Handler) // default

    app.Get("/swagger/*", swagger.New(swagger.Config{ // custom
        URL: "http://example.com/doc.json",
        ModelsExpandDepth: -1,
        DeepLinking: false,
    }))

    app.Listen(":8080")
}