golang-swagger

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

Updated May 9, 2026
One-click install
npx skills add https://github.com/LuminaVault/LuminaVaultShared --skill golang-swagger-luminavault
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: golang-swagger
Source: https://github.com/LuminaVault/LuminaVaultShared/tree/main/.agents/skills/golang-swagger
Command: npx skills add https://github.com/LuminaVault/LuminaVaultShared --skill golang-swagger-luminavault

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Go APIs lack built-in OpenAPI documentation, forcing developers to hand-write specs that drift out of sync with handlers. This Skill guides the annotation, generation, and serving of Swagger docs directly from Go source code using swaggo/swag. ## Core Features & Use Cases - Annotation Authoring: Write @Summary, @Param, @Success, @Router, and @Security comments on handlers, plus struct tags like swaggertype, enums, example, and swaggerignore. - Code Generation & Serving: Run swag init and swag fmt, then wire the Swagger UI endpoint for Gin, Echo, Fiber, Chi, or net/http with the correct swaggo integration package. - Security & Multi-Environment Setup: Define Bearer/JWT, OAuth2, API key, and Basic auth schemes, and override docs.SwaggerInfo host/basepath at runtime for staging and production deployments. - Use Case: You add a new GET /accounts/{id} endpoint in a Gin service. The Skill produces the full annotation block, regenerates docs/ with swag init, and confirms the endpoint appears with a lock icon in Swagger UI. ## Quick Start Add Swagger annotations to my Gin handlers and set up the Swagger UI endpoint so the generated docs are served at /swagger/index.html.

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 Gin API?▼

Annotate handlers with @Summary, @Param, @Success, and @Router comments, run swag init to generate the docs package, then register ginSwagger.WrapHandler on a /swagger/*any route. A blank import of the docs package is required or the UI loads empty.

How to document Go structs for Swagger with swaggo?▼

Use struct tags: example for sample values, enums for allowed values, minimum and maximum for numeric bounds, swaggertype to override detected types like time.Time or []byte, and swaggerignore:"true" to hide fields while keeping JSON serialization.

Which swaggo package works with Chi or net/http routers?▼

Chi, net/http, and Gorilla all use github.com/swaggo/http-swagger. Gin uses gin-swagger, Echo uses echo-swagger, and Fiber uses fiber-swagger. All integrations also require the shared github.com/swaggo/files package.

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

The generated docs package is not registered because the blank import _ "yourmodule/docs" is missing from main.go or server initialization. Add the import and restart the server; the UI will then load the spec.

How do I exclude internal endpoints from generated Swagger docs?▼

Run swag init with the --tags flag and the ! prefix, for example swag init --tags '!Internal,!Admin'. This excludes those tags at generation time without editing the generated swagger.json or writing custom filtering code.

Can Swagger host and base path change per environment in Go?▼

Yes. Import the docs package with a named import and override docs.SwaggerInfo.Host and docs.SwaggerInfo.BasePath at startup, typically from environment variables. This avoids regenerating the spec for each deployment environment.