golang-swagger

Generate Swagger/OpenAPI specs from swaggo/swag annotations in Go source.

4|Updated May 17, 2026
One-click install
npx skills add https://github.com/hellopoisonx/aim --skill golang-swagger-hellopoisonx
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-swagger
Source: https://github.com/hellopoisonx/aim/tree/main/skills/golang-swagger
Command: npx skills add https://github.com/hellopoisonx/aim --skill golang-swagger-hellopoisonx

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

golang-swagger reduces the gap between Go API implementations and published OpenAPI/Swagger documentation by ensuring handlers, models, and security requirements are consistently described through annotation-driven generation.

Core Features & Use Cases

  • Generates Swagger/OpenAPI specs with swaggo/swag: Produces docs from annotation comments such as @Summary, @Param, @Success, @Router, and @Security, then runs swag init to create the docs/ package.
  • Wires Swagger UI into multiple Go HTTP frameworks: Supports gin, echo, fiber, chi, and net/http integrations by registering the Swagger UI endpoint (commonly at /swagger/index.html).
  • Improves schema fidelity and security accuracy: Uses struct tags (swaggertype, enums, example, swaggerignore) and security definitions (Bearer/JWT, OAuth2, API key) so the UI reflects how clients must call your API.

Quick Start

Use the golang-swagger skill to annotate your Gin handlers with @Summary, @Param, @Success, and @Router, then run swag init to generate the docs package and mount the Swagger UI 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 generate Swagger documentation from Go code annotations?

To generate Swagger documentation from Go code, annotate handlers with swaggo/swag comments like @Summary, @Param, @Success, and @Router, then run swag init to produce the docs package. Struct tags on models control schema fidelity for request and response payloads.

Can I use swaggo/swag to document APIs across different Go HTTP frameworks?

Yes, swaggo/swag supports documenting REST APIs across multiple Go HTTP frameworks including gin, echo, fiber, chi, and net/http. You mount the generated Swagger UI endpoint, commonly at /swagger/index.html, by registering the docs package through framework-specific routing.

How do I define security requirements like Bearer JWT in Swagger annotations?

Define security requirements in Swagger annotations by using the @Security comment on handlers and configuring security definitions such as Bearer/JWT, OAuth2, or API key in the generated spec, ensuring the UI accurately reflects client authentication needs.

How do I control schema types and ignore fields in swaggo/swag generated docs?

Control schema types and ignore fields in swaggo/swag generated docs by applying struct tags like swaggertype for custom type mapping, enums for enumerated values, example for sample data, and swaggerignore to exclude fields from the Swagger spec entirely.

Why is my Swagger UI showing the wrong host or base path for my Go API?

Swagger UI may show the wrong host or base path because swag init generates static values. You must apply runtime SwaggerInfo overrides in your Go application initialization to dynamically set the correct host and base path before serving the UI.