golang-swagger

Generate Swagger/OpenAPI documentation from swaggo/swag annotations in Go HTTP APIs.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires go, swag, and includes references (resource) components.

What problem does it solve?

Swagger/OpenAPI specs often drift from real handler behavior because annotations are incomplete, misformatted, or missing security details, causing broken integrations and misleading API consumers.

Core Features & Use Cases

  • Generate Swagger UI specs from swaggo/swag annotations so your Go handlers become the source of truth for API behavior.
  • Document parameters, responses, and routing across common patterns like path/query/body params and structured success/failure responses.
  • Apply security schemes correctly (Bearer/JWT, OAuth2, API key, basic auth) and support AND/OR composition per endpoint.
  • Enrich and correct schemas via struct tags including examples, enums, swaggerignore, and swaggertype overrides for tricky Go types.
  • Keep docs maintainable across frameworks by wiring the Swagger UI for gin, echo, fiber, and net/http/chi.

Quick Start

Generate and serve Swagger for a gin app by running swag init, importing _ "yourmodule/docs", and registering the swagger route at /swagger/*any.

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 for Go APIs using swaggo annotations?

Generate Swagger documentation for Go APIs by translating swaggo/swag annotation comments into a runtime UI spec. Run swag init, import the generated docs package, and register the swagger route to serve the interactive UI directly from your handler code.

Why does my Swagger UI spec drift from my actual Go handler behavior?

Swagger UI specs drift from Go handler behavior when annotations are incomplete, misformatted, or missing security details. Enforcing swag-specific annotation and struct-tag conventions ensures correct schema generation and keeps documentation accurate and aligned with real API responses.

Can I use swag to document Go APIs built with gin, echo, fiber, or net/http?

Yes, swag supports documenting Go APIs built with gin, echo, fiber, and net/http/chi. You can wire the Swagger UI route for each framework to serve runtime OpenAPI documentation generated from your handler annotations.

How do I apply security schemes like Bearer JWT and OAuth2 in swaggo annotations?

Apply security schemes like Bearer JWT, OAuth2, API key, and basic auth by adding security annotations to your swaggo handlers. The tool supports AND/OR composition per endpoint to define complex security requirements accurately in the generated spec.

What's the best way to handle tricky Go types and schema overrides in Swagger documentation?

Handle tricky Go types and refine schemas using struct tags like swaggerignore and swaggertype overrides. You can also add examples and enums directly to your struct definitions to ensure correct OpenAPI schema generation.

Do I need to manually edit the generated Swagger YAML to override runtime documentation info?

No, you do not need to manually edit generated Swagger YAML to override documentation info. The tool satisfies required YAML-frontmatter discovery metadata and supports runtime docs.SwaggerInfo overrides to programmatically update title, version, and other details.