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
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 spec | generate a typed server / client / CLI | this site |
| Go interfaces, no codegen | hand-wire an untyped client or server | go-openapi/runtime |
| Go code | produce 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-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.