MCPcopy Index your code
hub / github.com/go-swagger/go-swagger

github.com/go-swagger/go-swagger @v0.35.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.35.0 ↗ · + Follow
1,576 symbols 7,247 edges 160 files 473 documented · 30% 5 cross-repo links updated 3d agov0.35.0 · 2026-06-26★ 9,992320 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Swagger 2.0

Tests Coverage CI vuln scan CodeQL

Release Container Registry on Quay.io Container Registry on Github

Go Report Card CodeFactor Grade

License Open SSF Scorecard OpenSSF Best Practices OpenSSF Baseline OSS licences status

Documentation GoDoc Discord Channel go version Top language Commits since latest release


This project contains a golang implementation of Swagger 2.0 (aka OpenAPI 2.0). It provide tools to work with swagger specifications.

Swagger is a simple yet powerful representation of your RESTful API.

Announcements

  • 2026-06-22 : v0.35.0 will land soon! (E.T.A end of June)
  • code generation: security fixes that prevent generated code to produce code injected from an erroneous or malicious spec. swagger validate now warns about possibly harmful $ref (e.g. from multiple origins).
  • spec generation: major bug-bashing action on go-openapi/codescan (which has eventually become fixable...). v0.35.0 closes ~200+ "generate spec" issues: bug fixes and requested enhancements. Spec generation now produces a detailed diagnostic of how your code annotations may be misinterpreted. A complete documentation site is now published at https://go-openapi.github.io/codescan/.
  • Please check it out from master (or dev docker image). Your feedback is super important!

  • 2026-06-22 : v0.36.0 will land in July

  • planned contents:
  • documentation: restyle doc site like go-openapi doc sites, dedicate doc for examples, cover a significant part of doc-related issues
  • spec generation: expect anoter small lots of feature for more control over your rendered specs. Codescan will publish its own lightweight CLI at a faster pace, as well as a TUI tool to instantly check how you annotated code looks like as a spec (preview: https://github.com/go-swagger/go-swagger/issues/3372#issuecomment-4733107554). We hope we'll be able to land a Web playground on a similar principle (WASI build on top of codescan). go-swagger will still receive updates.
  • code generation: we'll try our best land a few requested enhancements among the 50-60 reachable ones. (most issues in codegen now have hit an "architecture wall": work has started on a v2 to overcome these limitations).

  • 2026-05-28 : v0.34.0 ships!

  • major refactoring actions: the repo has been split in smaller chunks, easier to understand:
    • code examples have moved to go-swagger/examples, with a CI to automate code regeneration
    • codescan`` (the part that underpinsswagger generate spec) has moved as a standalone librarygo-openapi/codescan`. This library has been heavily refactored to prepare more significant improvements. The current version gets a few quirks already fixed.
    • diff (the implement of swagger diff) has joined go-openapi/analysis
    • package generator has been refactored to expose internal utilities (template repo, funcmaps, etc) as packages.
  • Generated code now requires go-openapi/runtime v0.32.x benefits from many bug fixes and here too a rechunking of the code.
  • Generated code now requires go-openapi/swag v0.26+ and directly imports all sub-modules.
  • Many long-awaited improvements on the generated client.
  • Feel free to join on Discord - Our Slack channel will be discontinued next month.

  • 2026-03-16 : v0.33.2 is out

  • upgraded requirement to go1.25
  • bug fix release
  • changes in our release workflow:
    • releases and tags are signed
    • all released artifacts are now signed. Signatures may be checked against .sig artifacts.
    • deb and rpm packages are available on a new package name go-swagger instead of swagger
    • docker images now embarks a go installation (required to generate code)
    • binary releases now ship as tarballs. See the updated installation instructions
    • for convenience, plain binaries with the pre-existing OS/arch naming convention has been maintained for now
  • removed dependencies:

  • 2026-03-16 : new community chat on discord

  • a new discord community channel is available to be notified of changes and support users
  • our venerable Slack channel remains open, and will be eventually discontinued on 2026-06-30
  • (for go-openapi libraries we'll stop Slack on 2026-03-31).

You may join the discord community by clicking the invite link on the discord badge (also above). Discord Channel.

Or join our Slack channel: Slack Channelslack-badge.

Documentation

https://goswagger.io

Features

go-swagger brings to the go community a complete suite of fully-featured, high-performance, API components to work with a Swagger API: server, client and data model.

  • Generates a server from a swagger specification
  • Generates a client from a swagger specification
  • Generates a CLI (command line tool) from a swagger specification (alpha stage)
  • Supports most features offered by jsonschema and swagger, including polymorphism
  • Generates a swagger specification from annotated go code
  • Additional tools to work with a swagger spec
  • Great customization features, with vendor extensions and customizable templates

Our focus with code generation is to produce idiomatic, fast go code, which plays nice with golint, go vet etc.

More details.

Project status

This project supports OpenAPI 2.0. At this moment it does not support OpenAPI 3.x.

go-swagger is now feature complete and has stabilized its API.

Most features and building blocks are now in a stable state, with a rich set of CI tests.

The go-openapi community actively continues bringing fixes and enhancements to this code base.

There is still much room for improvement: contributors and PR's are welcome. You may also get in touch with maintainers on our slack channel.

Installing

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

go-swagger is also available as binary or docker releases as well as from source: more details.

Try it

Try go-swagger in a free online workspace using Gitpod:

Open in Gitpod

Security

go-swagger turns an OpenAPI 2.0 specification into source code. Treat a specification like any other untrusted input: if you obtained it from a remote or untrusted location, review its contents before generating code from it.

The generator never executes the spec, and the generated code runs only when you build and import it. We have hardened the generators against an adversarial spec that tries to inject unwanted Go into the artifacts it produces — identifiers, struct tags, doc comments and CLI string literals are sanitized or escaped — which substantially reduces the exposure. It is not, however, a substitute for reviewing what you generate. In particular:

  • Remote $refs. A spec may reference other documents, possibly over the network. Those references are resolved and folded into the generated code, so inspect any external reference you do not control.
  • The x-go-type extension. By design, this extension lets the spec choose the Go type for a field — including an arbitrary imported package. That capability cannot easily be safeguarded: a spec using x-go-type can make your generated code import and depend on a package of its choosing. Always review specs that rely on it.

When in doubt, generate into a scratch directory, read the diff, and only then wire it into your build.

Licensing

The toolkit itself is licensed under an Apache Software License 2.0: SPDX-License-Identifier: Apache-2.0.

Just like swagger, this does not cover code generated by the toolkit. That code is entirely yours to license however you see fit.

Licence scan on dependencies

FOSSA Status

Extension points exported contracts — how you extend this code

AssetProvider (Interface)
AssetProvider provides access to embedded template assets. [2 implementers]
generator/internal/templates-repo/repository.go
Option (FuncType)
Option configures a [GenOpts] when building it with [NewGenOpts]. The option surface is intentionally small: presets ([
generator/options.go
ItemInterface (Interface)
swagger:model ItemInterface
fixtures/enhancements/pointers-nullable-by-default/item.go
GoModOption (FuncType)
(no doc)
hack/codegen_nonreg_test.go
FormatterFunc (FuncType)
FormatterFunc is a function that processes go code to reformat it, e.g. [golang.org/x/tools/imports.Process]). Formatti
generator/internal/language/options.go
MangleFunc (FuncType)
MangleFunc is a function that transforms a name string.
generator/internal/language/options.go
FormatOption (FuncType)
FormatOption allows for more flexible code formatting settings.
generator/internal/language/options.go
GoModOption (FuncType)
(no doc)
generator/internal/gentest/testutils.go

Core symbols most depended-on inside this repo

Execute
called by 274
cmd/swagger/commands/flatten_test.go
MustGet
called by 246
generator/internal/templates-repo/repository.go
FormatContent
called by 218
generator/internal/language/options.go
makeGenDefinition
called by 153
generator/model.go
apply
called by 81
cmd/swagger/commands/generate/shared.go
e
called by 78
docs/presentations/swagger-golangsf_files/play.js
MakeOperation
called by 70
generator/operation.go
p
called by 60
docs/presentations/swagger-golangsf_files/play.js

Shape

Function 1,059
Method 345
Struct 135
TypeAlias 25
FuncType 8
Interface 4

Languages

Go92%
TypeScript8%

Modules by API surface

generator/model_test.go97 symbols
docs/presentations/swagger-golangsf_files/play.js95 symbols
generator/structs.go94 symbols
generator/parameter_test.go60 symbols
generator/operation_test.go51 symbols
generator/moreschemavalidation_fixtures_test.go44 symbols
generator/model.go42 symbols
generator/operation.go41 symbols
generator/types.go39 symbols
hack/codegen_nonreg_test.go33 symbols
generator/internal/templates-repo/repository_test.go33 symbols
generator/schemavalidation_test.go32 symbols

Dependencies from manifests, versioned

dario.cat/mergov1.0.2 · 1×
github.com/Masterminds/goutilsv1.1.1 · 1×
github.com/Masterminds/semver/v3v3.5.0 · 1×
github.com/SladkyCitron/slogcolorv1.9.0 · 1×
github.com/davecgh/go-spewv1.1.2-0.20180830191 · 1×
github.com/felixge/httpsnoopv1.0.4 · 1×
github.com/go-openapi/analysisv0.25.2 · 1×
github.com/go-openapi/codescanv0.35.0 · 1×
github.com/go-openapi/errorsv0.22.8 · 1×

For agents

$ claude mcp add go-swagger \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact