Skip to content
123456890987654321 edited this page Jul 22, 2026 · 2 revisions

yaggo

Yet Another OpenAPI Go Generator — turns an OpenAPI 3.0.x or 3.1.x YAML spec into idiomatic, type-safe Go: structs, a chi server interface, an HTTP client, and authentication helpers driven by the spec's securitySchemes.

Quick start

go install github.com/123456890987654321/yaggo/cmd/yaggo@latest

yaggo -spec api.yaml -out ./gen -package api

Four files land in ./gen:

File Contents
types.go One Go type per components/schemas entry
server.go ServerInterface + RegisterHandlers(r chi.Router, ...)
client.go NewClient(baseURL, ...) with one method per operation
auth.go SecretString, generic auth helpers, and one named wrapper per components.securitySchemes entry
body_types.go Inline request-body structs (only when needed)

Navigation

Getting started

Generated code

  • Generated Types — schemas → structs, enums, allOf, nullability
  • Generated ServerServerInterface, chi wiring, error handling, response writers
  • Generated ClientNewClient, options, request editors, buffer pooling, body draining
  • AuthenticationSecretString, BasicAuth/BearerToken/APIKey, spec-driven wrappers

Reference

Project status

OpenAPI versions 3.0.x and 3.1.x
Go version 1.21+ (generated code uses generics and log/slog)
Server router chi v5
License MIT

Design goals

  1. Read the generated code. Output is gofmt-clean, hand-readable, and pinned to the smallest dependency surface possible (chi v5 in generated server, stdlib only in generated client and auth).
  2. Spec-driven, not reflection-driven. Type-safe method signatures, typed enums, typed auth wrappers — no any-soup at call sites.
  3. Secure defaults. HTTPS-only auth helpers with explicit opt-out. Secrets that redact themselves across fmt, JSON, log/slog, and encoding.TextMarshaler.
  4. Tested generated code. The end-to-end test suite generates the petstore package into a temp module and runs go test ./... against it on every CI run.

Clone this wiki locally