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{
HideSearch: false,
HideDownloadButtons: false,
HideSchemaTitles: false,
}),
)

Configuration Reference

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

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)
}