πŸ“– 2 min read (~ 400 words).

go-swagger examples

A curated collection of runnable examples for go-swagger β€” generating servers, clients and CLIs from an OpenAPI 2.0 (Swagger) spec.

Every example here is committed to the go-swagger/examples repository and kept in sync with the latest go-swagger release by automated regeneration.

Status

Fork me Actively maintained. Regenerated weekly against swagger@master.

Which site do I want?

These examples are all spec-first: you have an OpenAPI spec and want swagger generate to produce typed code. The sibling sites cover the other two approaches β€” pick by what you start from:

I start from…I want…Go here
an OpenAPI specgenerate a typed server / client / CLIthis site
Go interfaces, no codegenhand-wire an untyped client or servergo-openapi/runtime
Go codeproduce a spec from the code (code-first)go-openapi/codescan

New to go-swagger?

Install the toolchain and read the command reference on go-swagger’s own site:

go install github.com/go-swagger/go-swagger/cmd/swagger@latest

β†’ go-swagger.io for install, the generate command families, and project-layout reference. This site assumes you have swagger on your PATH and focuses on what to build with it.

Where to go next

  • Guides

    The example catalog, grouped by concern β€” servers, clients & CLI, authentication, streaming, and codegen customization. One page per example.

    β†’ guides

  • Tutorials

    Sequential, end-to-end walkthroughs. Start with the todo-list tutorial to build a server and client from scratch.

    β†’ tutorials

  • Project

    Repository README, licensing, contributing guidelines and how the examples stay in sync with go-swagger.

    β†’ project

Licensing

SPDX-FileCopyrightText: Copyright 2025 go-swagger maintainers

These examples ship under the Apache-2.0 license.

Contributing

Issues and pull requests welcome. See project/ for guidelines.


  • The example catalog, grouped by concern. Each page covers one runnable example: what it demonstrates, the spec excerpt, the generate command, how to run it, and the key generated files to look at.
  • Sequential, end-to-end walkthroughs. Unlike the guides β€” which are reference recipes you dip into β€” these build something from scratch, step by step. Start with the todo-list to generate both a server and a client.
  • About the go-swagger/examples repository β€” licensing, contributing, and how the examples are kept in sync with go-swagger.