mrkeyoor.comAsk

oapi-codegen/oapi-codegentested 04 Oct 2026commit 43281d1

oapi-codegen review

Consider oapi-codegen for a Go team that owns its OpenAPI contract and can review generated output.

  • Install 19 s
  • Build 35 s
6/6tests passed
  • 56 packages
Dev Toolsevaluationupdated 26 Oct 2026
+2stars / 7d

oapi-codegen generates Go models, API clients and server boilerplate from OpenAPI 3.0 and 3.1 specifications. You implement the application logic. Generated interfaces and request handling reduce boilerplate, but do not establish that your application follows every part of its contract.

Verdict

Consider oapi-codegen for a Go team that owns its OpenAPI contract and can review generated output. Our October 4, 2026 run at commit 43281d1 completed its recorded setup, build and test steps successfully. It did not verify CLI installation, exhaustive unique test coverage or correctness on your specification. Before adopting it, compile a representative generated client or server and check strict responses, schema merging and request validation with the exact version and configuration you intend to ship.

We ran it

Lab card: what happened when we ran oapi-codegen
Lab card from our sandbox run
Screenshot of oapi-codegen (github.com/oapi-codegen/oapi-codegen)
github.com/oapi-codegen/oapi-codegen
Install✓ · 19s56 packages
Build✓ · 35s
Tests✓ · 13s6 passed · 0 failed of 6 (go test)
Repo2099 files~687,215 lines of source · 24.7 MB · 7 CI workflows

Answers from our run

Does oapi-codegen build from source?

Dependencies installed in 19 seconds (56 packages), and the build succeeded in 35 seconds. We cloned commit 43281d1 into a clean Debian container with 3 CPUs and no project-specific setup.

Do oapi-codegen's tests pass?

Yes. The project's own test command finished in 13 seconds and reported 6 passed, 0 failed (go test).

Who should not use oapi-codegen?

Projects that need to generate directly from Swagger/OpenAPI 2.0 without conversion.

What are the alternatives to oapi-codegen?

ogen, go-swagger. Consider oapi-codegen for a Go team that owns its OpenAPI contract and can review generated output.

Setup3/5The October 4, 2026 run at 43281d1 completed setup, build and test steps successfully and downloaded Go 1.25.0. CLI installation and generation from a representative application specification were not verified.
Docs4/5The supplied README documents tool installation, configuration, server requirements, strict-mode limits, import mapping and compatibility boundaries. It warns that development documentation can include unreleased changes.
Community2/5The supplied issues show maintainer and contributor discussion and references to fixes. They do not establish adoption, support response times or an independently verified current activity count.
Maturity3/5The project documents compatibility boundaries and v2.8.0 upgrade requirements. Schema-merging behavior and strict-response fixes require version-specific verification; our run did not validate those cases.

Discussed on

  1. hnLessons learned from `oapi-codegen`'s time in the GitHub Secure Open Source Fund21 points
  2. hnOpenAPI Client and Server Code Generator for Golang3 points

Who it’s for

Go teams using an OpenAPI specification as the contract for clients or servers.
API owners using the documented net/http, Chi, Echo, Fiber, Gin, gorilla/mux or Iris targets.
Developers who want YAML configuration, go:generate integration and import mapping across specifications.
Teams prepared to pin the generator and review and compile its output against their own specifications.

Who it’s NOT for

Projects that need to generate directly from Swagger/OpenAPI 2.0 without conversion.
Teams expecting strict-server generation to validate incoming requests automatically.
Users expecting stable template overrides or stable imports throughout pkg: the README explicitly limits those compatibility promises.
Organizations requiring a verified self-contained output mode: issue 2342 discusses that request and experimental work, rather than establishing its availability in the reviewed generator.

Setup reality

In our recorded run on October 4, 2026, commit 43281d18a9d0d4adc921a2e697147aaf63fd6479 completed the setup step in 19.212 seconds, the build step in 34.702 seconds and the test step in 13.432 seconds, each with exit code 0. The harness recorded 70 seconds overall and a dependency count of 56. These records do not establish that a CLI binary was installed or checked.

The configured image was golang:1.24-bookworm, with 3 CPUs and 8 GB of memory. The setup log records downloading go1.25.0, so this is not evidence that the generator builds using Go 1.24. The README requires Go 1.25 or newer to build and install it.

The test parser recorded 6 successful package results and no failures, but the retained tail repeats three package names beneath a summary marker. Exhaustive unique test coverage was not verified. No application workload, generated client/server integration, installed-binary check or security audit is established by this record.

For adoption, choose a generator version, match its configuration schema, generate from your specification and compile the result. The v2.8.0 release notes require runtime v1.6.0 or newer for features including duration handling, escaped path parameters and typed response headers.

Go generation with application work still to do

oapi-codegen generates Go models, clients and server boilerplate from OpenAPI 3.0 and 3.1. It is worth considering when your team wants the specification to define its API boundaries while keeping handler implementations in application code.

The README documents nine server targets: Chi, Echo, Echo v5, Fiber, Fiber v3, Gin, gorilla/mux, Iris and net/http. Its generated-code requirements differ by target: Echo v5, Fiber v3 and Gin require Go 1.25 or newer; the other listed targets require Go 1.24 or newer. The generator itself requires Go 1.25 or newer. The development README warns that it can describe unreleased changes, so check the documentation for your chosen release.

Strict mode generates request and response objects and handles more marshaling around your implementation. It still requires another server target, and the README explicitly says it does not include incoming-request validation. Treat validation and authentication as application integration work. The v2.8.0 release notes direct authentication and authorization into request-validation middleware that evaluates the specification's security requirements.

What our recorded run establishes

Our recorded run took place on October 4, 2026 at commit 43281d18a9d0d4adc921a2e697147aaf63fd6479. Setup took 19.212 seconds, the build step took 34.702 seconds and the test step took 13.432 seconds. All three returned exit code 0. The build tail also records vet-exit:0. The harness reports 70 seconds overall; that total is distinct from the individual step durations.

The configured sandbox had 3 CPUs, 8 GB of memory and image golang:1.24-bookworm. Crucially, the setup tail says it downloaded go1.25.0. The image label therefore does not demonstrate Go 1.24 compatibility. Successful setup-step execution also does not establish that an installed oapi-codegen binary was checked.

The dependency metric was 56. It is not a count of packages installed as executables or audited for security. The checkout metrics were 2,099 files, approximately 687,215 source lines and 24.7 MB. The detector found seven CI workflows and no root Dockerfile, Compose file or tests directory; those directory signals do not describe test coverage.

The parser recorded six successful package results, zero failed results and two packages without test files. However, the retained test tail shows three successful package names repeated beneath a summary marker. We have not reconciled a complete log or verified an exhaustive unique count. The supported conclusion is that the recorded test command succeeded, rather than that six distinct tests or all repository test targets passed.

This run contains no measured generation workload, generated application integration test, installed-binary check or security audit. It supports a source-checkout trial, not a ranking against other generators.

Check fixes against the version you will use

Version 2.8.0 introduced initial OpenAPI 3.1 support. Its release notes describe webhooks, callbacks, type-array nullability and flexible enums. Initial support is not a promise that every specification maps cleanly into Go.

Issue 2525 reports a specific strict-server failure: a response body that lowers to any produced a receiver type Go rejects. The supplied issue extract still labels the issue open, but also records September 28, 2026 commits referencing a fix for untyped strict response bodies. That evidence makes a blanket warning that current strict-server output is broken misleading. It does not establish which released version contains the fix, or that our run exercised the affected schemas. Generate and compile those response shapes with your pinned version.

Issue 2107 has a clearer configuration distinction. It was closed as completed in September 2026. A maintainer's September 26 comment says main supports property merging through compatibility.schema-merging-behavior set to v3. The comment says v3 merges declarations instead of replacing a colliding property wholesale, while v2 retains the older behavior. At the time of that comment, v3 was optional and unreleased. Do not assume either that the limitation remains universal or that every release enables the new behavior by default.

For strict servers using import mapping, the README also requires destination specifications containing referenced response or request-body components to generate strict-server output. Otherwise, the required envelope types can be missing.

Pin the parts and inspect the generated result

The README recommends managing the generator as a Go tool, using YAML configuration and matching the editor configuration schema to the generator version. Template overrides are explicitly unstable. Imports under pkg are also considered unstable except for Generate and its related Configuration surface; the command-line interface and configuration format have a stronger compatibility promise.

The v2.8.0 release notes require runtime v1.6.0 or newer when regenerating code that uses the release's new runtime features. They also describe changed net/http trailing-slash routing and the removal of generated security-scope context machinery by default. Review these behavior changes alongside compilation results when upgrading.

A useful next step is to generate from a representative specification using your chosen version, compile the output and review the diff. Include fixtures for schema merging, strict responses and external references, then exercise request validation and authentication in your application. Those checks answer the adoption question more directly than checkout size or a successful repository test command.

How to read the scores

These are editorial assessments of the supplied evidence, not benchmark results. The scale is 1 for a demonstrated major obstacle, 2 for limited evidence or substantial unresolved requirements, 3 for a usable documented path with material verification still needed, 4 for strong relevant evidence with stated limits and 5 for comprehensive verification of that dimension. Unknown adoption or compatibility does not earn a high score. Community receives 2 because the extracts show maintainer and contributor discussion but do not establish adoption or response times.

Alternatives

ProjectWhat it isPick it when
ogenAn OpenAPI v3 generator for Go with typed clients and servers and specification-based generated validation.Consider it when generated validation is a requirement. Its README documents that capability; this review does not establish comparative validation coverage or performance.
go-swaggerGo tooling for Swagger/OpenAPI 2.0, including client, server and model generation.Choose it for a Swagger/OpenAPI 2.0 contract you want to keep in that format. Its README explicitly says it does not support OpenAPI 3.x.

What people are saying

  1. [github-trending] oapi-codegen/oapi-codegen

Sources

  1. oapi-codegen README
  2. oapi-codegen v2.8.0 release
  3. Strict any response compile issue 2525
  4. allOf property merging issue 2107
  5. Self-contained output request 2342

More dev tools reviews