You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
go get -u github.com/swaggo/swag/cmd/swag
# Go 1.25 or newer
go install github.com/swaggo/swag/cmd/swag@latest
Run the Swag in your Go project root folder which contains main.go file, Swag will parse comments and generate required files(docs folder and docs/doc.go).
package main
import (
"github.com/gofiber/swagger/v2""github.com/gofiber/fiber/v3"// docs are generated by Swag CLI, you have to import them.// replace with your own docs folder, usually "github.com/username/reponame/docs"
_ "github.com/gofiber/swagger/example/docs"
)
// @title Fiber Example API// @version 1.0// @description This is a sample swagger for Fiber// @termsOfService https://swagger.io/terms/// @contact.name API Support// @contact.email fiber@swagger.io// @license.name Apache 2.0// @license.url https://www.apache.org/licenses/LICENSE-2.0.html// @host localhost:8080// @BasePath /funcmain() {
app:=fiber.New()
app.Get("/swagger/*", swagger.HandlerDefault) // defaultapp.Get("/swagger/*", swagger.New(swagger.Config{ // customURL: "https://example.com/doc.json",
DeepLinking: false,
// Expand ("list") or Collapse ("none") tag groups by defaultDocExpansion: "none",
// Prefill OAuth ClientId on Authorize popupOAuth: &swagger.OAuthConfig{
AppName: "OAuth Provider",
ClientId: "21bb4edc-05a7-4afc-86f1-2e151e4ba6e2",
},
// Ability to change OAuth2 redirect uri locationOAuth2RedirectUrl: "https://localhost:8080/swagger/oauth2-redirect.html",
}))
app.Listen(":8080")
}