Spec Forge uses AST-based static analysis to extract OpenAPI specs from Gin projects — zero annotations required.
The dominant solution (swaggo/swag) requires hundreds of verbose annotations:
// @Summary Get user by ID
// @Param id path int true "User ID"
// @Success 200 {object} User
// @Router /users/{id} [get]
func GetUser(c *gin.Context) { ... }These annotations are not validated by the Go compiler — typos and stale references only surface at generation time. Renaming a type means manually updating annotations everywhere.
Spec Forge requires zero annotations. It uses Go AST analysis to read your routes, handler signatures, and struct definitions directly from source.
- Detection: Parses
go.modto detect Gin dependency - Patching: No-op (no dependencies to install)
- Generation: Uses Go AST parser to extract routes, handlers, and types
- Direct route registration:
r.GET("/users", handler) - Route groups:
api := r.Group("/api") - Middleware chains:
r.Use(auth).GET("/protected", handler) - Parameter binding:
c.Param(),c.Query(),c.ShouldBindJSON() - Response types: extracted from
c.JSON()calls with type inference
# Basic generation
cd my-gin-project
spec-forge generate . -o ./openapi
# Generate with AI enrichment (configure .spec-forge.yaml first)
spec-forge generate . --language zh
# Verbose mode to see extraction details
spec-forge generate . -v