Skip to content

Codegen: add fiber v3 support - #1937

Closed
kerak19 wants to merge 5 commits into
oapi-codegen:mainfrom
kerak19:lo-fiber-v3
Closed

Codegen: add fiber v3 support#1937
kerak19 wants to merge 5 commits into
oapi-codegen:mainfrom
kerak19:lo-fiber-v3

Conversation

@kerak19

@kerak19 kerak19 commented Mar 23, 2025

Copy link
Copy Markdown
Contributor

This PR adds Fiber v3 support to oapi-codegen.

While Fiber v3 is not yet production ready per link, any code changes concerning oapi code generation should've been easy to manage.

Added petstore-expanded and minimal-server examples.
Updated Readme to contain Fiber v3 paragraph.

kerak19 added 5 commits March 23, 2025 21:47
Important change: the GenerateImports now accepts whole configuration, so it can use the information to know which version of package to import.

Currently it's only used for fiber but in the future can be used for any other import with major version increment
@kerak19
kerak19 requested a review from a team as a code owner March 23, 2025 20:58
Comment thread examples/go.mod
gopkg.in/yaml.v3 v3.0.1 // indirect
)

replace github.com/oapi-codegen/fiber-middleware/v2 => github.com/kerak19/fiber-middleware/v2 v2.0.0-20250323205111-59ed66807d2f

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@socket-security

Copy link
Copy Markdown

@jamietanna

Copy link
Copy Markdown
Member

I'll try and get a review at some point - if Fiber are still pushing out breaking changes to v3 I'd be concerned that this may mean we'll have more work keeping this working 🤔

@lcapka

lcapka commented Feb 3, 2026

Copy link
Copy Markdown

Hi guys, any plans to finish this topic?

@byte-bandit

Copy link
Copy Markdown

I'm also curious, fiber v3 has been stable for a while and is the new de-facto standard over there. The code generator needs a bit of tweaking (Context() no longer returns a `fasthttp.Request, but the majority of this change still works.

@kerak19

kerak19 commented Feb 14, 2026

Copy link
Copy Markdown
Contributor Author

Looks like fiber v3 released recently: https://github.com/gofiber/fiber/releases/tag/v3.0.0

@jamietanna if you agree I can update this PR

@matyaskzs

Copy link
Copy Markdown

@jamietanna please forgive the annoyance, but naturally there are some breaking changes between fiber v2 and v3. Would it be possible to merge this PR?

@dillonbuchanan-maia-tech

Copy link
Copy Markdown
Contributor

I took the PR that @kerak19 and resolved the merge conflicts as well as some of the other issues.

@mromaszewicz

Copy link
Copy Markdown
Member

Thanks for doing this, but I've merged a different, more recent PR, which adds Fiber V3 support to a supported version:
#2431

mromaszewicz added a commit that referenced this pull request Jul 9, 2026
Add fiber v3 server support

Add a `fiber-v3-server` generation target (fiber v3 requires Go 1.25+),
continuing #1937.

- Add `fiber-v3` and `strict-fiber-v3` template sets, derived from the
  fiber v2 templates and adapted to the fiber v3 API: `fiber.Ctx` is
  passed by value, request bodies use `ctx.Bind().Body`, scopes are set
  via `c.RequestCtx().SetUserValue`, and `GetReqHeaders` returns
  `map[string][]string`.
- Wire up generation: the `fiber-v3-server` config flag (plus the
  deprecated `-generate fiber-v3` CLI alias), imports via
  `GenerateOptions.RouterImports()`, the single-server validation check,
  and the JSON configuration schema. No changes to any existing
  exported API.
- Document it in the README server table and docs/fiber-v3-server.md.
- Add minimal-server and petstore-expanded examples, depending on the
  released github.com/oapi-codegen/fiber-v3-middleware v0.1.0 and
  gofiber/fiber/v3 v3.4.0.

Co-authored-by: Łukasz Opasiak <lukasz.opasiak@proton.me>
Co-authored-by: Marcin Romaszewicz <marcinr@gmail.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants