go-swagger-helper

Maintain Go Swagger annotations and regenerate Swagger documentation for gin projects.

Updated May 11, 2025
One-click install
npx skills add https://github.com/LeiZhang-Hunter/nova-factory-server --skill go-swagger-helper
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-swagger-helper
Source: https://github.com/LeiZhang-Hunter/nova-factory-server/tree/main/.trae/skills/go-swagger-helper
Command: npx skills add https://github.com/LeiZhang-Hunter/nova-factory-server --skill go-swagger-helper

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents Swagger documentation from drifting out of sync with your Go gin controllers by ensuring annotations and generated docs are updated whenever routes, handlers, or request/response models change.

Core Features & Use Cases

  • Auto-maintenance of Swagger annotations: Helps you add or update @Summary, @Description, @Tags, @Param, @Success, and @Router in existing or new controller handlers.
  • Consistent project conventions: Aligns Swagger entrypoint routing, docs package usage, and generation tooling with repository conventions like app/routes/routes.go and app/docs.
  • Generation and troubleshooting guidance: Provides a clear workflow for running make swag (or cd app/ && swag init) and diagnosing common swag init failures such as model parsing issues or missing endpoints.

Quick Start

Ask the Skill: "Update the Swagger annotations for this gin controller handler and regenerate the Swagger docs so the endpoint appears in the Swagger UI."

Frequently Asked Questions about go-swagger-helper

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I update Swagger annotations in Go gin controllers?

To update Swagger annotations in Go gin controllers, modify the @Summary, @Description, @Tags, @Param, @Success, and @Router comments above your handler functions to match the new binding logic and routing paths.

Why does swag init fail to parse my Go request models?

Swag init fails to parse Go request models when Swagger annotations lack proper @Param and @Success alignment with the actual struct definitions, or when the command runs outside the expected project directory structure.

What is the correct command to regenerate Swagger documentation for a gin project?

The correct command to regenerate Swagger documentation for a gin project is running `make swag` from the root directory, or executing `cd app/ && swag init` to ensure the tool parses the correct routes and docs package locations.

How do I fix a missing endpoint in Swagger UI after adding a new gin route?

To fix a missing endpoint in Swagger UI after adding a new gin route, ensure the controller handler has matching @Router annotations and regenerate the docs by running `make swag` to update the swagger.json file.

Does this Swagger annotation workflow support custom RBAC request models?

Yes, this Swagger annotation workflow supports custom RBAC request models by ensuring the @Param annotations correctly align with your RBAC struct binding logic, allowing swag init to successfully parse the security definitions.

What are the limitations of relying on swag init for API documentation?

A limitation of relying on swag init for API documentation is that generated docs drift out of sync if developers forget to run `make swag` after modifying gin controllers, routes, or request/response models.