Middleware for Gin web servers that serves automatically generated Swagger 2.0 documentation for REST APIs. Works with the swag tool and generated docs package.
Overview
Gin Swagger is middleware you add to a Gin HTTP application so clients can browse REST API documentation in Swagger 2.0 format. It is meant to be used together with swag, which reads API comment annotations and writes a docs folder and Go package that describe your routes.
After annotating handlers and running swag init, you import the generated docs and register the middleware on your Gin router. The middleware can point at the API definition URL, control how tags and operations expand in the UI, enable deep linking, tune model display, and keep OAuth authorization data across reloads when configured.
The project supports multiple swagger document instances on one router via instance names, nested project layouts, and configuration options introduced in newer swag releases. It targets teams already using Gin who want interactive API docs without maintaining a separate specification by hand.
Key features
- Swagger 2.0 REST API docs UI
- Gin router middleware integration
- Configurable Swagger UI options
- Multiple swagger instances per router
- OAuth2 dialog defaults
- Works with swag-generated docs
- Nested directory project support
- Persist authorization in browser
Use cases
- Documenting Gin REST services
- Interactive API exploration during development
- Serving OpenAPI-style docs from Go comments
- Multiple API surfaces on one Gin app