Tools to generate and test golang code.
- 2026-06-22 : new community chat on discord
- a new discord community channel is available to be notified of changes and support users
You may join the discord community by clicking the invite link on the discord badge (also above).
Early days. The API has stabilized.
Yet it needs its first consumer (github.com/go-swagger/go-swagger) to be wired against it. This may incur a few minor changes to the API.
go get github.com/go-openapi/codegen/{module}go-openapi/codegen exposes a collection of code generation tools and utilities.
formatting: go code formatting, including imports resolution and go.mod formattingfuncmaps: useful pre-assembled funcmapsgenapp: a composable app-generator to build clean, formatted go codegentesting: tools to test generated code from their behavior and desired propertiesmangling: name mangling utilities to produce clean go identifiers (this is the successor ofgithub.com/go-openapi/swag/mangling)templates-repo: a repository to cache templates with a unified namespace (this is the successor ofgithub.com/go-swagger/go-swagger/generator/internal/templates-repo)
The root module github.com/go-openapi/codegen at the repo level maintains a few
dependencies outside of the standard library and golang.org packages:
github.com/go-openapi/inflect: a pluralizer for English words - we'll eventually transfer this functionality inmanglinggithub.com/go-openapi/swag/conv: go-openapi's type conversion utilitiesgithub.com/go-openapi/swag/pools: go-openapi's memory pooling utilitiesgithub.com/go-openapi/testify/v2: go-openapi's test assertion library, a fork ofstretchr/testify
- package
genappcalls go commands such asgo mod tidyand requires a go compiler installed to support all features.
- importing
github.com/go-openapi/codegen/formatting/enable/gofumptimportsgofumptso formatting may apply its rules (stricter than the standardgofmt).
mangling/ucd: our internal tables for unicode transliteration, maintained from the standard unicode tables
All kinds of contributions are welcome.
This repo is a go mono-repo.
More general guidelines are available here.
-
go-swaggerto be the first consumer of this library, which is intended to support code-generation first apps. -
mangling: stable API.- Next: backport a reduced version of
inflectto support English pluralization of single words. - Future/Maybe - Leads for future enhancements, but no immediat plans:
- improve unicode transliteration (greek is not bad, but cyrillic is not really good)
- unicode transliteration for CJK Han and Korean Hangul (help needed)
- kit to build custom transformers
- Next: backport a reduced version of
-
formatting: stable API. No immediate plans. -
funcmaps: stable API. New funcmap bundles to be added, possibly the current go-swagger one. -
genapp: stable API. No immediate plans. -
templates-repo: stable API. No immediate plans. -
[]
gentesting: test utilities to runn blackbox tests on generated code. New library to be added.
See https://github.com/go-openapi/codegen/releases
This library ships under the SPDX-License-Identifier: Apache-2.0.
Maintainers can cut a new release by running:
- running this workflow