On this page
Overview
Swag parses declarative comments in Go source and generates API documentation. It is centered on Swagger 2.0, while the v2 line expands OpenAPI v3 support, and it integrates with common Go web frameworks and Swagger UI workflows.
Features and best fit
Based on official documentation; not hands-on tested · Content checked:
Key features
Generate API operations and schemas from annotations near handlers
General API metadata, routes, parameters, responses, and security can be described in comments, then swag init generates docs.go plus JSON or YAML specifications.
Sources: [2]
Best fit
Fits Go web APIs that want documentation maintained close to handler source
It is useful when teams want annotations beside Gin or other handlers and generated specifications for Swagger UI, clients, or publishing during builds.
Sources: [2]
Before adoption
v2.0.0-rc6 is a release candidate; go.mod declares Go 1.18 while source-build docs say Go 1.19+
The v2.0.0-rc6 go.mod declares Go 1.18, while the README asks for Go 1.19 or newer to build from source. Since v2 remains in RC with active OpenAPI v3 changes, pin the generator and regression-test annotation parsing plus generated-spec diffs.
Official sources
- [1]swaggo/swag — GitHub repository(2026-10-06)
- [2]Swag v2.0.0-rc6 — README(2026-10-06)
- [3]Swag v2.0.0-rc6 — go.mod(2026-10-06)
- [4]Swag v2.0.0-rc6 release(2026-10-06)
- [5]Swag MIT license(2026-10-06)
Supplemental curator note
Swag generates API documentation from comments near Go handlers and integrates with common web frameworks. Because the v2 line is currently a release candidate, pin the generator version and review generated specification diffs in CI, especially when using OpenAPI v3 features.
Try it in 3 steps
- 1
Get the source
git clone --depth 1 https://github.com/swaggo/swag.git - 2
Enter the repository
cd swag - 3
Check the official steps
Continue with the commands in the README Installation, Quick Start, or Getting Started section.
find . -maxdepth 1 -iname 'README*' -exec sed -n '1,220p' {} \; -quit
Growth
Growth trends · Last 30 days
13,040 Stars
Trend data is still being collected.
Development activity
Last 90 days · weekly
- Commits (last 30 days)
- 5
- Open PRs
- 63
Development activity is still being collected.
Built with
Categories and tags
Categories
GitHub data
GitHub dataView detailed GitHub data
GitHub Topics
- golang
- swagger
- swagger2
- annotations
- openapi
Related information
Write a related articleShare a guide or use case for this OSS in Markdown. Articles are published after administrator approval.
Explore next
- Chi22,929 Stars
2 shared tag(s) · 1 shared category(s) · Same language
compose Go HTTP routes and middleware while keeping net/http compatibility
Go - Apache Casbin20,433 Stars
2 shared tag(s) · 1 shared category(s) · Same language
separate ACL, RBAC, and ABAC authorization policies from Go application code
Go - imgproxy11,109 Stars
2 shared tag(s) · 1 shared category(s) · Same language
offload application image processing to a standalone HTTP service
Go - golang-jwt9,229 Stars
2 shared tag(s) · 1 shared category(s) · Same language
create, sign, parse, and validate JSON Web Tokens in Go
Go - Bifrost8,576 Stars
2 shared tag(s) · 1 shared category(s) · Same language
centralize multiple LLM providers behind one high-performance gateway
Go - OpenSERP1,447 Stars
2 shared tag(s) · 1 shared category(s) · Same language
combine multiple search services and content extraction behind one API
Go
Report incorrect information
Tell us if any listing information is incorrect or outdated.