# oapi-codegen/oapi-codegen

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/oapi-codegen-oapi-codegen).**

8,088 stars · 1,014 forks · Go · apache-2.0

## Links

- GitHub: https://github.com/oapi-codegen/oapi-codegen
- awesome-repositories: https://awesome-repositories.com/repository/oapi-codegen-oapi-codegen.md

## Topics

`go` `golang` `openapi` `openapi-codegen` `openapi-generator` `openapi3` `rest-api` `rest-api-client` `swagger`

## Description

oapi-codegen is an OpenAPI specification compiler and code generator for Go. It transforms OpenAPI definitions into type-safe Go client libraries, server boilerplate, and data models to facilitate contract-first API development.

The tool distinguishes itself through a flexible customization system that allows users to override generated types and imports via specification extensions. It supports the use of custom text templates to redefine the final source code structure and provides a specification overlay mechanism to modify or remove endpoints without altering the original source file.

The generator covers a broad range of capabilities including the synthesis of strict server interfaces for request handling, the creation of production-ready HTTP clients, and the mapping of server URLs. It also produces middleware for API request validation and provides specialized handling for nullable types to distinguish between omitted and null values.

## Tags

### Development Tools & Productivity

- [API-First Development Toolsets](https://awesome-repositories.com/f/development-tools-productivity/compilers-toolchains/source-compilation-tools/source-generators/api-first-development-toolsets.md) — Provides a complete toolset for contract-first development by generating both server boilerplate and client libraries from a spec.
- [Server Boilerplate Generators](https://awesome-repositories.com/f/development-tools-productivity/type-safe-binding-generators/server-boilerplate-generators.md) — Automates the creation of server-side boilerplate and request handlers based on API schema definitions.
- [Strict Interface Generators](https://awesome-repositories.com/f/development-tools-productivity/type-safe-binding-generators/server-boilerplate-generators/strict-interface-generators.md) — Generates high-guardrail server interfaces that automate data marshalling and enforce strict type bindings. ([source](https://github.com/oapi-codegen/oapi-codegen#readme))
- [Contract Generation Tools](https://awesome-repositories.com/f/development-tools-productivity/contract-generation-tools.md) — Derives executable Go code and data models directly from API specification metadata.
- [Type Customization Extensions](https://awesome-repositories.com/f/development-tools-productivity/type-definition-generators/type-customization-extensions.md) — Provides a system to override generated Go type names, imports, and tags via specification extensions. ([source](https://github.com/oapi-codegen/oapi-codegen#readme))

### Software Engineering & Architecture

- [API Client Generators](https://awesome-repositories.com/f/software-engineering-architecture/api-client-generators.md) — Generates production-ready, type-safe Go HTTP client libraries based on OpenAPI specifications. ([source](https://github.com/oapi-codegen/oapi-codegen#readme))
- [Interface Contracts](https://awesome-repositories.com/f/software-engineering-architecture/interface-contracts.md) — Provides strict server-side signatures and client methods that enforce consistency between the API specification and the implementation.
- [Data Model Generators](https://awesome-repositories.com/f/software-engineering-architecture/openapi-specification-parsers/data-model-generators.md) — Generates strongly typed Go structures and data models directly from OpenAPI schema definitions. ([source](https://github.com/oapi-codegen/oapi-codegen#readme))
- [Go Code Generators](https://awesome-repositories.com/f/software-engineering-architecture/openapi-specification-parsers/go-code-generators.md) — Compiles OpenAPI specifications into type-safe Go client libraries and server boilerplate.
- [Specification Extensions](https://awesome-repositories.com/f/software-engineering-architecture/specification-extensions.md) — Allows the use of custom specification extensions to control generated types, imports, and tags.
- [Specification Overlays](https://awesome-repositories.com/f/software-engineering-architecture/specification-overlays.md) — Supports modifying the input API specification using external structural delta files before code generation.

### Data & Databases

- [Schema Type Synchronization](https://awesome-repositories.com/f/data-databases/data-type-definitions/schema-type-synchronization.md) — Automatically translates OpenAPI schema definitions into type-safe Go data structures.
- [Client Library Generation](https://awesome-repositories.com/f/data-databases/openapi-processors/client-library-generation.md) — Transforms OpenAPI specifications into production-ready, type-safe Go client libraries.
- [Server Stub Generation](https://awesome-repositories.com/f/data-databases/openapi-processors/server-stub-generation.md) — Creates server-side boilerplate and routing logic to automate the implementation of the defined API. ([source](https://github.com/oapi-codegen/oapi-codegen#readme))
- [OpenAPI Processors](https://awesome-repositories.com/f/data-databases/openapi-processors.md) — Processes OpenAPI YAML and JSON files to produce idiomatic Go types and validation middleware.

### Programming Languages & Runtimes

- [Go Code Generators](https://awesome-repositories.com/f/programming-languages-runtimes/go-code-generators.md) — Creates type definitions and server interfaces in Go to automate API routing and data structures. ([source](https://github.com/oapi-codegen/oapi-codegen/blob/main/examples/minimal-server/chi/api/impl.go))
- [Type Safety](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/type-system-tools/type-safety.md) — Ensures API type safety by generating strict Go definitions that enforce the specification's data integrity.
- [Source Code Templates](https://awesome-repositories.com/f/programming-languages-runtimes/source-code-compilers/source-code-templates.md) — Produces Go source code by injecting parsed specification data into customizable text templates.
- [Nullability Wrappers](https://awesome-repositories.com/f/programming-languages-runtimes/type-wrappers/nullability-wrappers.md) — Implements specialized nullable wrappers to distinguish between omitted fields and explicit null values in API requests. ([source](https://github.com/oapi-codegen/oapi-codegen#readme))

### User Interface & Experience

- [Generation Templates](https://awesome-repositories.com/f/user-interface-experience/layout-utilities/presentation-engines/template-engines/configuration-and-integration/custom-template-integrations/generation-templates.md) — Allows replacing default generation logic with custom text templates to change the final code structure. ([source](https://github.com/oapi-codegen/oapi-codegen/blob/main/README.md))

### Web Development

- [Request Validation Middleware](https://awesome-repositories.com/f/web-development/request-validation-middleware.md) — Provides automated middleware to verify that incoming HTTP requests strictly adhere to the OpenAPI specification. ([source](https://github.com/oapi-codegen/oapi-codegen#readme))
