Gin Docs
Zero-annotation API documentation generator for Go applications using Gin and GORM. Automatically introspects your router tree, reads struct tags via reflection, generates a full OpenAPI 3.1 spec, and serves interactive Swagger UI or Scalar documentation — all with a single gindocs.Mount() call. Supports GORM model variants (Create/Update schemas), fluent route overrides, Postman/Insomnia export, and JWT/API key auth in the Try It panel.
What's Included
Installation
$ go get github.com/MUKE-coder/gin-docsHow to Use
Install the package
Add Gin Docs to your Go project.
go get github.com/MUKE-coder/gin-docsMount with one line
Pass your Gin router and optional GORM database to auto-generate docs from your existing routes and models.
import "github.com/MUKE-coder/gin-docs/gindocs"
r := gin.Default()
// Define your routes as usual
r.GET("/api/users", listUsersHandler)
r.POST("/api/users", createUserHandler)
// One line to generate docs
gindocs.Mount(r, db)
r.Run(":8080")Open the documentation
Navigate to /docs in your browser for interactive API documentation. Switch between Swagger UI and Scalar via query parameter.
# Open http://localhost:8080/docs
# Swagger UI: http://localhost:8080/docs?ui=swagger
# Scalar UI: http://localhost:8080/docs?ui=scalar
# OpenAPI spec: http://localhost:8080/docs/openapi.jsonCustomize with config & overrides
Add metadata, register GORM models for auto-generated schemas, configure auth, and override specific route docs with a fluent API.
docs := gindocs.Mount(r, db, gindocs.Config{
Title: "My API",
Version: "1.0.0",
UI: gindocs.UIScalar,
Auth: gindocs.AuthConfig{
Type: gindocs.AuthBearer,
BearerFormat: "JWT",
},
Models: []interface{}{User{}, Post{}},
})
docs.Route("POST /api/users").
Summary("Register a new user").
RequestBody(CreateUserInput{}).
Response(201, User{}, "User created")Free to use · MIT License