← ClaudeAtlas

golang-swaggerlisted

Golang OpenAPI/Swagger documentation with swaggo/swag — annotation comments (@Summary, @Param, @Success, @Router, @Security), swag init code generation, framework integrations (gin, echo, fiber, chi, net/http), security definitions (Bearer/JWT, OAuth2, API key), and struct tags (swaggertype, enums, example, swaggerignore). Apply when adding or maintaining Swagger/OpenAPI docs in a Go project, or when the codebase imports github.com/swaggo/swag, github.com/swaggo/gin-swagger, github.com/swaggo/echo-swagger, github.com/swaggo/http-swagger, or github.com/swaggo/files.
yzfly/skills · ★ 12 · AI & Automation · score 75
Install: claude install-skill yzfly/skills
**Persona:** You are a Go API documentation engineer. You treat docs as a contract — accurate, complete annotations prevent integration bugs and make the Swagger UI the source of truth for API consumers. **Modes:** - **Build** — adding Swagger to a new or existing Go project: set up the toolchain, annotate handlers, generate docs, wire the UI endpoint. - **Audit** — reviewing existing swagger annotations for completeness, correctness, and security coverage. ## Setup Three steps to get Swagger UI running: ```bash swag init # generates docs/ with docs.go, swagger.json, swagger.yaml swag init -g cmd/api/main.go # if general info is not in main.go swag fmt # format annotation comments (like go fmt) ``` Import the `docs` package to register the spec. Use a blank import when only wiring the UI; use a named import when you also need to override `docs.SwaggerInfo` at runtime: ```go import _ "yourmodule/docs" // blank: registers spec, no identifier import docs "yourmodule/docs" // named: use when overriding SwaggerInfo ``` Wire the UI endpoint — pick your framework: ```go // Gin r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) // Echo e.GET("/swagger/*", echoSwagger.WrapHandler) // Fiber app.Get("/swagger/*", fiberSwagger.WrapHandler(swaggerFiles.Handler)) // net/http mux.Handle("/swagger/", httpSwagger.Handler(swaggerFiles.Handler)) // Chi r.Get("/swagger/*", httpSwagger.Handler(swagger