golang-swagger

Generate Swagger and OpenAPI documentation for Go APIs with swag init.

2|Updated Mar 13, 2023
One-click install
npx skills add https://github.com/haipham22/golang-sample --skill golang-swagger-haipham22
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: golang-swagger
Source: https://github.com/haipham22/golang-sample/tree/main/.agents/skills/golang-swagger
Command: npx skills add https://github.com/haipham22/golang-sample --skill golang-swagger-haipham22

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you create and maintain accurate Swagger and OpenAPI documentation for Go APIs so the generated spec matches your handlers, models, security rules, and runtime configuration.

Core Features & Use Cases

  • Annotate handlers with summary, parameter, response, routing, and security metadata that Swagger UI can render correctly.
  • Set up Swagger UI for Gin, Echo, Fiber, Chi, and net/http using the appropriate integration package and docs import pattern.
  • Document models with struct tags for examples, enums, limits, ignored fields, and type overrides for timestamps and binary data.
  • Handle advanced API documentation needs such as nested response envelopes, generic responses, API key and JWT security, OAuth2, and environment-specific host or base path overrides.
  • Use the bundled CLI guidance to generate, format, filter, and maintain specs with swag init and swag fmt.

Quick Start

Use this skill to add or audit Swagger annotations for your Go API, then wire the correct generated docs package and 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 generate Swagger documentation for a Go API using swag annotations?

To generate Swagger documentation for a Go API, you annotate handlers with summary, parameter, response, and routing metadata, then use swag init to generate the spec. This Skill guides structuring annotations so Swagger UI renders them correctly.

Can I set up Swagger UI with Gin, Echo, Fiber, and Chi in Go?

Yes, you can set up Swagger UI with Gin, Echo, Fiber, Chi, and net/http. This Skill provides the appropriate integration package imports and docs wiring patterns required to serve the generated OpenAPI spec for each framework.

How do I document Go struct tags for Swagger enums, examples, and ignored fields?

Document Go struct tags for Swagger by applying annotations for examples, enums, limits, and ignored fields. This Skill helps you accurately model response schemas, handle type overrides for timestamps, and document binary data within structs.

Does swaggo support JWT, API key security definitions, and OAuth2 in Go?

Yes, swaggo supports API key, JWT security definitions, and OAuth2 in Go. This Skill demonstrates annotation patterns to correctly model authentication, nested response envelopes, and generic responses within OpenAPI security definitions.

What is the best way to override the host and base path in a generated OpenAPI spec?

Override the host and base path in a generated OpenAPI spec using dynamic spec overrides. This Skill covers environment-specific configurations and generated spec maintenance to ensure documentation matches runtime configuration rules.

Why does swag fmt fail to format my Go Swagger annotations correctly?

Swag fmt fails to format Go Swagger annotations correctly when syntax is malformed or struct tags are misaligned. This Skill provides CLI guidance to generate, format, filter, and maintain specs properly using swag init and swag fmt.