Skip to content

Commit

Permalink
fixup! Add Config.FileContent
Browse files Browse the repository at this point in the history
  • Loading branch information
willfaught committed Apr 26, 2024
1 parent ac66002 commit f0070f2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ title: Swagger
![Security](https://github.com/gofiber/contrib/workflows/Security/badge.svg)
![Linter](https://github.com/gofiber/contrib/workflows/Linter/badge.svg)

Swagger middleware for [Fiber](https://github.com/gofiber/fiber). The middleware handles Swagger UI.
Swagger middleware for [Fiber](https://github.com/gofiber/fiber). The middleware handles Swagger UI.

**Note: Requires Go 1.18 and above**

Expand Down Expand Up @@ -63,6 +63,19 @@ cfg := swagger.Config{
app.Use(swagger.New(cfg))
```

Use program data for Swagger content:
```go
cfg := swagger.Config{
BasePath: "/",
FilePath: "./docs/swagger.json",
FileContent: mySwaggerByteSlice,
Path: "swagger",
Title: "Swagger API Docs",
}

app.Use(swagger.New(cfg))
```

Using multiple instances of Swagger:
```go
// Create Swagger middleware for v1
Expand Down Expand Up @@ -102,6 +115,12 @@ type Config struct {
// Optional. Default: ./swagger.json
FilePath string

// FileContent for the content of the swagger.json or swagger.yaml file.
// If provided, FilePath will not be read.
//
// Optional. Default: nil
FileContent []byte

// Path combines with BasePath for the full UI path
//
// Optional. Default: docs
Expand Down

0 comments on commit f0070f2

Please sign in to comment.