📖 2 min read (~ 300 words).

Repository README

This site documents the go-swagger/examples repository — a collection of runnable, committed examples for go-swagger, the spec-first code generator for OpenAPI 2.0 (Swagger).

What’s here

Every example is a real Go project generated from an OpenAPI 2.0 spec: servers, typed client SDKs, and CLIs. The generated code is committed and kept in sync with go-swagger master by automated regeneration, so what you read on this site matches what the current generator emits.

Browse the material two ways:

  • Guides — reference recipes you dip into (servers, clients & CLI, authentication, streaming, customizing codegen).
  • Tutorials — sequential, end-to-end walkthroughs that build something from scratch.

Where this fits — three sibling sites

go-swagger and go-openapi split their example material across three sites by workflow. This one is the spec-first corner: you write an OpenAPI spec and generate typed Go from it.

SiteWorkflowYou start from
this sitespec-first codegenan OpenAPI 2.0 spec → generated server/client/CLI
go-openapi/runtimeuntyped / hand-wiredthe runtime API, no codegen
go-openapi/codescancode-firstGo code → generated spec

When a topic straddles two workflows, the page links across.

Getting started

git clone https://github.com/go-swagger/examples

You’ll need the swagger CLI on your PATH to regenerate or follow the tutorials — see the installation instructions. Then head to the todo-list tutorial to build a server and client from one spec.

Status & releasing

The examples track go-swagger code generation for servers and clients. The repository is deliberately left unreleased: it follows the generator on go-swagger/go-swagger@master rather than tagging versions of its own.

Licensing

This software ships under the Apache-2.0 license.

Other documentation