golang-swagger

Generate Swagger/OpenAPI documentation from Go code using swaggo annotations.

1|Updated Mar 21, 2026
One-click install
npx skills add https://github.com/dashkan/pivox --skill golang-swagger
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-swagger
Source: https://github.com/dashkan/pivox/tree/main/.agents/skills/golang-swagger
Command: npx skills add https://github.com/dashkan/pivox --skill golang-swagger

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It prevents Swagger/OpenAPI specs from becoming incomplete or misleading when you add or change Go API endpoints, so consumers can integrate confidently.

Core Features & Use Cases

  • Annotate handlers as contract-first docs: Add precise @Summary, @Param, @Success/@Failure, @Router, and @Security blocks so the UI reflects real behavior.
  • Generate and wire Swagger UI: Run swag init/swag fmt to produce the docs/ artifacts and expose them at a framework route like /swagger/index.html.
  • Model schemas accurately: Use struct tags like enums, examples, swaggerignore, and swaggertype to correct edge cases (time.Time, []byte, ignored fields).
  • Apply security and filtering: Define security schemes once and apply per route, and use swag init tag selection to exclude internal/admin endpoints.

Quick Start

Use swag init to generate the docs, then wire the Swagger UI route in your server and ensure your handlers include standard swaggo annotations for parameters, responses, routing, and security.

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, convert swaggo annotations like @Param, @Success, and @Router into a correct OpenAPI spec by running swag init to produce the docs/ artifacts. This ensures your API documentation accurately reflects your REST endpoints.

How do I wire Swagger UI into a Go web framework?

You wire Swagger UI by running swag init to generate the docs/ artifacts, then exposing them at a framework route like /swagger/index.html. This integration requires using the swaggo/swag CLI alongside framework-specific integration packages for your Go server.

How do I handle time.Time and []byte fields in OpenAPI model schemas?

Correct OpenAPI model schemas for time.Time and []byte edge cases use struct tags like swaggertype and swaggerignore. These tags adjust the generated spec to accurately represent request and response schemas, including examples and ignored fields.

How do I apply security annotations to specific Go API routes?

To apply security annotations, define your security schemes once and apply the @Security annotation per route. This ensures your Swagger UI accurately represents the required authentication for specific REST endpoints without repeating scheme definitions.

Can I exclude internal or admin endpoints from my generated Swagger spec?

Yes, you can exclude internal or admin endpoints from your Swagger spec by using swag init tag selection. This filtering mechanism prevents specific API routes from being included in the final OpenAPI documentation generated from your Go code.

Why is my generated OpenAPI spec misleading after adding new Go endpoints?

Your generated OpenAPI spec becomes misleading if swaggo annotations do not match the real behavior of new Go endpoints. Adding precise @Summary, @Param, @Success/@Failure, and @Router blocks ensures the Swagger UI reflects actual API request and response schemas.