go-swagger3¶
Generate OpenAPI 3 specs from Go code annotations. go-swagger3 reads swag-style @ comments and struct tags,
writes an OpenAPI 3.0 document (JSON or YAML), and serves it with Swagger UI
from the web framework you already use.
// @Title Get a pet
// @Param id path int true "Pet ID"
// @Success 200 object Pet "The pet"
// @Route /pets/{id} [get]
func GetPet(c *gin.Context) { /* ... */ }
go install github.com/parvez3019/go-swagger3@latest
go-swagger3 --module-path . --output oas.json --schema-without-pkg
Get started with your framework¶
| Framework | Guide |
|---|---|
| Gin | OpenAPI 3 with Gin |
| Echo | OpenAPI 3 with Echo |
| chi | OpenAPI 3 with chi |
| Fiber | OpenAPI 3 with Fiber |
| Hertz | OpenAPI 3 with Hertz |
| gorilla/mux | OpenAPI 3 with gorilla/mux |
| net/http | OpenAPI 3 with net/http |
Buffalo, Flamingo and Atreugo adapters are listed in Serving Swagger UI.
Reference¶
| Page | Contents |
|---|---|
| Install & CLI | go install, prebuilt binaries, Docker; flags; go-swagger3 fmt |
| Annotation reference | Service info, parameters, headers, responses, tags, routes, struct tags, enums, generics |
| Security | HTTP, API key, OpenID Connect and OAuth2 schemes; scopes |
| Serving Swagger UI | net/http handler and all framework adapters |
Coming from swaggo/swag?¶
- go-swagger3 vs swaggo/swag vs go-swagger: which tool outputs what.
- Migrating from swaggo/swag: annotation-by-annotation mapping.
More¶
- AI agent skills for Claude Code and Cursor.
- Examples: runnable net/http, Gin, Echo and chi samples.
- Releases and changelog.