Skip to main content

ReDoc

ReDoc renders API documentation in a clean three-column format, ideal for read-only documentation and executive-facing API summaries.

Installation​

go get github.com/oaswrap/spec-ui/redoc

Usage​

import (
specui "github.com/oaswrap/spec-ui"
"github.com/oaswrap/spec-ui/redoc"
)

handler := specui.NewHandler(
specui.WithTitle("My API"),
specui.WithSpecFile("openapi.yaml"),
redoc.WithUI(),
)

With Configuration​

import (
"github.com/oaswrap/spec-ui/config"
"github.com/oaswrap/spec-ui/redoc"
)

handler := specui.NewHandler(
specui.WithTitle("My API"),
specui.WithSpecFile("openapi.yaml"),
redoc.WithUI(config.ReDoc{
HideDownloadButtons: false,
HideSchemaTitles: false,
}),
)

Configuration Reference​

FieldTypeDefaultDescription
HideDownloadButtonsboolfalseHide the "Download" button for the API definition
HideSchemaTitlesboolfalseHide schema titles in the documentation

ReDoc 3: Search is always enabled in ReDoc 3, so HideSearch was removed in spec-ui v0.2.2. Delete it from your config.ReDoc{...} — it no longer compiles. The ReDoc page also disables usage telemetry and makes no external font requests.

Embedded Mode​

Use redocemb for air-gapped deployments:

import "github.com/oaswrap/spec-ui/redocemb"

handler := specui.NewHandler(
specui.WithSpecFile("openapi.yaml"),
redocemb.WithUI(),
)

if handler.AssetsEnabled() {
r.Get(handler.AssetsPath()+"/*", handler.Assets().ServeHTTP)
}