golang-swagger

Generates and audits OpenAPI/Swagger documentation for Go APIs using swaggo/swag annotations.

1|Updated Jun 2, 2026
One-click install
npx skills add https://github.com/VerifiedOrganic/onboard --skill golang-swagger-verifiedorganic
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-swagger
Source: https://github.com/VerifiedOrganic/onboard/tree/main/.agents/skills/golang-swagger
Command: npx skills add https://github.com/VerifiedOrganic/onboard --skill golang-swagger-verifiedorganic

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires github.com/swaggo/swag, and includes references (resource) components.

What problem does it solve? Go APIs often ship without accurate OpenAPI documentation, or their Swagger specs drift out of sync with the actual handlers. This Skill guides the creation and auditing of swaggo/swag annotation comments so the generated Swagger UI stays a correct, complete contract for API consumers. ## Core Features & Use Cases - Build mode: Set up the swag toolchain, annotate handlers with @Summary, @Param, @Success, @Router, and @Security, run swag init, and wire the Swagger UI endpoint for Gin, Echo, Fiber, Chi, or net/http. - Audit mode: Review existing annotations for completeness, correctness, and security coverage, catching common mistakes like missing docs imports, stale generated specs, or unprotected routes lacking @Security. - Struct enrichment: Apply struct tags such as swaggertype, enums, example, minimum/maximum, and swaggerignore so generated schemas reflect real types like time.Time and []byte. - Use Case: You inherit a Gin service with no API docs. The Skill walks you through adding general API info in main.go, annotating each handler, defining Bearer JWT security, running swag init, and serving the UI at /swagger/index.html. ## Quick Start Ask the agent to add Swagger annotations to your Go handlers and generate the docs with swag init, then wire the Swagger UI route for your framework.

Frequently Asked Questions about golang-swagger

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add Swagger documentation to a Go API?▼

Install the swag CLI, add general API info annotations in main.go, annotate each handler with @Summary, @Param, @Success, and @Router comments, then run swag init to generate the docs folder. Wire the UI with your framework's swaggo integration package such as gin-swagger or http-swagger.

How do I set up Swagger UI with Gin in Go?▼

Import github.com/swaggo/gin-swagger and github.com/swaggo/files, add a blank import of your generated docs package, then register r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)). The UI is served at /swagger/index.html.

Why is my Swagger UI empty after running swag init?▼

The most common cause is a missing blank import of the generated docs package, so the spec never registers. Add import _ "yourmodule/docs" in main.go or your server setup, and re-run swag init after any annotation changes.

How do I document time.Time or []byte fields in swaggo?▼

Use the swaggertype struct tag to override the detected type, for example swaggertype:"string" with format:"date-time" for time.Time, or swaggertype:"string" with format:"base64" for []byte. Without the override, swag generates incorrect schemas for these types.

Does swaggo support JWT or OAuth2 security definitions?▼

Yes. Define schemes once at the API level with @securityDefinitions annotations for apikey (Bearer/JWT), basic auth, or OAuth2 flows, then apply them per endpoint with @Security. Use && on a single line when multiple schemes are both required.

How do I exclude endpoints from the generated Swagger spec?▼

Run swag init with the --tags flag using the ! prefix to exclude tags, for example swag init --tags '!Internal,!Admin'. This filters endpoints at generation time without editing the generated JSON or writing custom code.