Skip to content

OpenAPI

Imports: []*dygo.Module{openapi.Module(openapi.Options{
Info: openapi.Info{Title: "Users API", Version: "1.0"},
BearerAuth: true,
})}
r = r.Prefix("/users").Use(openapi.Tags("users"), openapi.Response(401, "Missing token"))
r.Get("/{id}", dygo.Handle(c.Get), openapi.Summary("Get a user"), openapi.Response(404, "No such user"))

GET /openapi.json and Swagger UI at GET /docs. Nothing else to annotate: parameters come from the In tags, the body from Body, the response from Out. validate:"...", default, description and example tags add constraints and docs. openapi.Public() removes the auth requirement from an operation; openapi.Exclude() hides a route. openapi.Generate(app.Routes(), opts) builds the document without serving it, for a file or a CI check.