Freedom251 › API Generation Software
oapi-codegen

What oapi-codegen is
oapi-codegen is a command-line tool and Go library that generates server implementations, API clients, and HTTP models from OpenAPI specifications. It supports OpenAPI 3.0 and 3.1, including 3.1 webhooks and nullable type forms, but not OpenAPI 2.0 (Swagger). Server boilerplate is available for Chi, Echo, Echo v5, Fiber, Fiber v3, Gin, gorilla/mux, Iris, and net/http. Strict server generation handles multiple request and response media types and status codes, form requests, marshaling, and response status and content-type handling. Generated clients can use a custom HTTP client and return either raw HTTP responses or parsed data. Large specifications can be divided across Go packages using import mapping or external references. Developers can override templates and use supported OpenAPI extensions to customize generated output. YAML configuration includes a JSON Schema for editor suggestions, and the CLI and configuration format are classed as stable. The open-source tool is free and can be installed as a Go tool or binary and used with go:generate. Building and installing it requires Go 1.25 or newer, though generated code may need an older version depending on the server backend.
Who it suits
It suits Go developers generating server code, clients, or HTTP models from OpenAPI 3.x specifications. It also offers customization options for teams with specific generation needs.
What it does well
- Generates Go servers, clients, and HTTP models.
- Supports OpenAPI 3.0 and 3.1.
- Server boilerplate covers multiple Go frameworks.
- Custom templates and OpenAPI extensions can shape output.
- YAML configuration includes a JSON Schema.
What to know first
- Does not support OpenAPI 2.0 (Swagger).
- Building and installing requires Go 1.25 or newer.
- Only the latest minor release receives active development support.
- Some imported package internals and template overrides are unstable.
Limits
Building and installing requires Go 1.25 or newer. OpenAPI 2.0 specifications are unsupported, and active development support covers only the latest minor release.
Plans
| Plan | Billed and limits | Price |
|---|---|---|
| Open source | OpenAPI-to-Go code generation; Go 1.25+ required to build and install | Free |
As github.com lists them, read 4 Oct 2026. The maker's own page has the final word.
Getting started
- Install Go 1.25 or newer
- Install oapi-codegen as a Go tool or binary
- Prepare an OpenAPI 3.0 or 3.1 specification
- Configure generation with YAML if needed
- Run the command-line tool or invoke it through go:generate
- Select a supported Go server backend
Verdict
oapi-codegen covers several Go server backends and client generation, with customization for generated output. Its OpenAPI 2.0 exclusion and version requirements are key limits to check.
Questions
What does oapi-codegen generate?
It generates Go server implementations, API clients, and HTTP models from OpenAPI specifications.
Which OpenAPI versions are supported?
OpenAPI 3.0 and 3.1 are supported, including 3.1 webhooks and nullable type forms. OpenAPI 2.0 (Swagger) is not supported.
Is oapi-codegen free?
Yes. It is open source, with an Open source plan priced at $0.
Which server frameworks can it target?
Generation supports Chi, Echo, Echo v5, Fiber, Fiber v3, Gin, gorilla/mux, Iris, and net/http.
Can generated output be customized?
Yes. Go templates can be overridden, and supported OpenAPI extensions can customize generated types, names, JSON behavior, and struct tags.
What is required to install it?
Building and installing oapi-codegen requires Go 1.25 or newer. It can be installed as a Go tool or binary and used with go:generate.
Facts from oapi-codegen's own pages
- Compatibility limits
- Only the latest minor release receives active development support, bug fixes are not backported, and some imported package internals and template overrides are described as unstable. · github.com, 4 Oct 2026
- Configuration
- The tool uses YAML configuration and provides a JSON Schema for editor suggestions; its command-line interface and configuration format are classed as stable. · github.com, 4 Oct 2026
- Customization
- Generated Go templates can be overridden, and supported OpenAPI extensions can customize generated types, names, JSON behavior, and struct tags. · github.com, 4 Oct 2026
- Generated clients
- Generated clients can use a custom HTTP client and can return either a raw HTTP response or parsed response data. · github.com, 4 Oct 2026
- Integrations
- It can be installed as a Go tool or binary and used with go:generate; the project also documents Renovate for updating a pinned configuration schema. · github.com, 4 Oct 2026
- Large specifications
- The tool can split large OpenAPI specifications across multiple Go packages using import mapping or external references. · github.com, 4 Oct 2026
- OpenAPI support
- It supports OpenAPI 3.0 and 3.1, including 3.1 webhooks and nullable type forms; it does not support OpenAPI 2.0 (Swagger). · github.com, 4 Oct 2026
- Purpose
- oapi-codegen is a command-line tool and library that converts OpenAPI specifications into Go server implementations, API clients, and HTTP models. · github.com, 4 Oct 2026
- Requirements
- Building and installing oapi-codegen requires Go 1.25 or newer; generated code can have lower Go version requirements depending on the server backend. · github.com, 4 Oct 2026
- Security
- The project links to an organizational security policy and says it may make breaking changes if needed to respond to a security vulnerability. · github.com, 4 Oct 2026
- Server generation
- It generates server boilerplate for Chi, Echo, Echo v5, Fiber, Fiber v3, Gin, gorilla/mux, Iris, and net/http. · github.com, 4 Oct 2026
- Strict server
- Strict server generation supports multiple request and response media types and status codes, form requests, automatic marshaling, and response status and content-type handling. · github.com, 4 Oct 2026
- Support
- The maintainers describe support as best-efforts because they work on the project during off hours from their jobs. · github.com, 4 Oct 2026
Where oapi-codegen stands on Freedom251
- API Generation Software#9 of 25
- Code Generators#21 of 33