Skip to content
go-openapiPublic

About

Tools to generate and test golang code

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

codegen

Tests Coverage CI vuln scan CodeQL

Release CodeFactor Grade License

GoDoc Discord Channel go version Top language Commits since latest release


Tools to generate and test golang code.

Announcements

  • 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). Discord Channel

Status

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.

Import this library in your project

go get github.com/go-openapi/codegen/{module}

Contents

go-openapi/codegen exposes a collection of code generation tools and utilities.

  • formatting: go code formatting, including imports resolution and go.mod formatting
  • funcmaps: useful pre-assembled funcmaps
  • genapp: a composable app-generator to build clean, formatted go code
  • gentesting: tools to test generated code from their behavior and desired properties
  • mangling: name mangling utilities to produce clean go identifiers (this is the successor of github.com/go-openapi/swag/mangling)
  • templates-repo: a repository to cache templates with a unified namespace (this is the successor of github.com/go-swagger/go-swagger/generator/internal/templates-repo)

Dependencies

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 in mangling
  • github.com/go-openapi/swag/conv: go-openapi's type conversion utilities
  • github.com/go-openapi/swag/pools: go-openapi's memory pooling utilities
  • github.com/go-openapi/testify/v2: go-openapi's test assertion library, a fork of stretchr/testify

Runtime dependencies

  • package genapp calls go commands such as go mod tidy and requires a go compiler installed to support all features.

Optional dependencies

  • importing github.com/go-openapi/codegen/formatting/enable/gofumpt imports gofumpt so formatting may apply its rules (stricter than the standard gofmt).

Test or internal usage only

  • mangling/ucd: our internal tables for unicode transliteration, maintained from the standard unicode tables

Note to contributors

All kinds of contributions are welcome.

This repo is a go mono-repo.

More general guidelines are available here.

Roadmap

  • go-swagger to 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 inflect to 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
  • 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.

Change log

See https://github.com/go-openapi/codegen/releases

Licensing

This library ships under the SPDX-License-Identifier: Apache-2.0.

Cutting a new release

Maintainers can cut a new release by running:

About

Tools to generate and test golang code

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages