-
Notifications
You must be signed in to change notification settings - Fork 46
feat: prepare swagger v3 for Fiber v3 #114
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,9 @@ | ||
| module github.com/gofiber/swagger | ||
| module github.com/gofiber/swagger/v3 | ||
|
|
||
| go 1.18 | ||
| go 1.25 | ||
|
|
||
| require ( | ||
| github.com/gofiber/fiber/v2 v2.52.6 | ||
| github.com/gofiber/fiber/v3 v3.0.0-rc.2 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| github.com/swaggo/files/v2 v2.0.2 | ||
| github.com/swaggo/swag v1.16.4 | ||
| ) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,9 +8,9 @@ | |
| "strings" | ||
| "sync" | ||
|
|
||
| "github.com/gofiber/fiber/v2" | ||
| "github.com/gofiber/fiber/v2/middleware/filesystem" | ||
| "github.com/gofiber/fiber/v2/utils" | ||
| "github.com/gofiber/fiber/v3" | ||
|
Check failure on line 11 in swagger.go
|
||
| "github.com/gofiber/fiber/v3/middleware/filesystem" | ||
|
Check failure on line 12 in swagger.go
|
||
| "github.com/gofiber/fiber/v3/utils" | ||
|
Check failure on line 13 in swagger.go
|
||
|
Comment on lines
+11
to
+13
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify API compatibility with Fiber v3. The import paths have been updated correctly. However, ensure that the Fiber v3 APIs used in this file (filesystem middleware at line 37, Ctx methods at lines 58-73, and utils at line 58) remain compatible with v3. Based on learnings, Fiber v3 introduces several API changes including router signature changes and the extractors package for middleware. Please verify that:
Run the tests after 🏁 Script executed: #!/bin/bash
# Run tests with v3 dependencies
go mod tidy && go test -v ./...Length of output: 93 🏁 Script executed: #!/bin/bash
# Find go.mod file in the repository
echo "=== Locating go.mod file ==="
fd -H "go.mod$" -t f
echo ""
echo "=== Locating swagger.go file ==="
fd -H "swagger.go$" -t f
echo ""
echo "=== Repository structure (first 2 levels) ==="
find . -maxdepth 2 -type f -name "*.go" | head -20Length of output: 181 🏁 Script executed: #!/bin/bash
# Examine swagger.go content
echo "=== Full swagger.go content ==="
cat swagger.go
echo ""
echo "=== Go.mod for dependency info ==="
cat go.modLength of output: 3384 🌐 Web query: 💡 Result: Short summary — Fiber v3 Ctx API for route/path/method:
Docs: Fiber Ctx reference (Ctx.Route / Path / Method) and App routing docs. [1] https://docs.gofiber.io/api/ctx [2] https://docs.gofiber.io/next/api/app 🌐 Web query: 💡 Result: Short summary (Fiber v3)
Sources: Fiber docs and pkg reference. [1] [2] [3] 🌐 Web query: 💡 Result: Short answer: In GoFiber v3 use c.Type(ext, charset...) to set the response Content-Type by extension (e.g. "json", ".html", "png"). It returns *Ctx so it's chainable. Example: app.Get("/", func(c *fiber.Ctx) error { Notes:
Sources: 🌐 Web query: 💡 Result: Short answer: In Fiber v3 the old middleware/filesystem was replaced by the new static middleware. Instead of Config.Root (http.FileSystem) on filesystem.Config you now pass the filesystem path or an fs.FS to static.New — or use the contrib/filesystem package which still accepts an http.FileSystem Root. Example usages:
Reference: Fiber v3 static docs and v3 "What's New" (filesystem -> static), and v2 filesystem Config docs. [1] [3] [2] 🌐 Web query: 💡 Result: Short answer: Fiber v3 removed the middleware/filesystem package — you should use the static middleware (static.New with FS: os.DirFS / http.FS / embed.FS or static.Config) instead. See the v3 "What's New" / migration notes and the static middleware docs for examples. [1][2][3] References:
🌐 Web query: 💡 Result: In Fiber v3 the old filesystem middleware was removed from the core — use the new static middleware (which covers filesystem use-cases) or mount an http.FileSystem via static.Config.FS. See Fiber v3 notes and the static middleware docs for examples. [1][2] Sources: 🌐 Web query: 💡 Result: CopyString (in gofiber/utils) makes a heap-allocated copy of a context-derived string by copying its underlying bytes into a new []byte and converting that to string — so the result won't be overwritten by future requests. In practice it does the same as: buffer := make([]byte, len(s)) In Fiber v3 the utils helpers (including utils.CopyString) are provided from the external module github.com/gofiber/utils/v2. [1][2] Sources: The filesystem middleware was removed in Fiber v3 and must be updated. The Ctx methods ( Line 37's 🧰 Tools🪛 GitHub Actions: Tests[error] 11-11: missing go.sum entry for module providing package github.com/gofiber/fiber/v3 (imported by github.com/gofiber/swagger/v3); to add: go mod tidy 🪛 GitHub Check: golangci[failure] 11-11: [golangci] swagger.go#L11 [failure] 12-12: [golangci] swagger.go#L12 [failure] 13-13: [golangci] swagger.go#L13 🪛 GitHub Check: Tests (1.20.x, ubuntu-latest)[failure] 13-13: [failure] 12-12: [failure] 11-11: 🪛 GitHub Check: Tests (1.21.x, ubuntu-latest)[failure] 13-13: [failure] 12-12: [failure] 11-11: 🤖 Prompt for AI Agents |
||
| swaggerFiles "github.com/swaggo/files/v2" | ||
| "github.com/swaggo/swag" | ||
| ) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The indentation in this Go code example is inconsistent. Some lines use spaces while others use tabs. It's best practice to format Go code with
gofmt, which uses tabs for indentation. This will improve readability and consistency.