README.md
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.
You may join the discord community by clicking the invite link on the discord badge. .
2026-07-20 : v0.36.0 will land in July (soon!)
2026-07-20 : v0.35.1 landed!
2026-06-22 : v0.35.0 landed! (end of June)
2026-05-28 : v0.34.0 ships!
go-swagger/examples, with a CI to automate code regenerationcodescan (the part that underpins swagger generate spec) has moved as a standalone
library go-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/analysisgenerator has been refactored to expose internal utilities (template repo, funcmaps, etc)
as packages.go-openapi/runtime v0.32.x and benefits from many bug fixes and there too a
rechunking of the code.go-openapi/swag v0.26+ and directly imports all sub-modules.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.
Our focus with code generation is to produce idiomatic, fast go code, which plays nice with golint, go vet etc.
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 .
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 go-swagger in a free online workspace using Gitpod:
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:
$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.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.
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.