Skip to main content

RapiDoc

RapiDoc is a web component-based API viewer with multiple themes, layout options, and distinctive tabular and tree-based schema representations. It's well-suited for large or complex API specifications.

Installation

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

Usage

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

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

With Configuration

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

handler := specui.NewHandler(
specui.WithTitle("My API"),
specui.WithSpecFile("openapi.yaml"),
rapidoc.WithUI(config.RapiDoc{
Theme: "dark",
Layout: "row",
RenderStyle: "read",
SchemaStyle: "table",
PrimaryColor: "#FF791A",
}),
)

Configuration Reference

FieldTypeDefaultDescription
Themestring"light"Theme: "light" or "dark"
Layoutstring"row"Layout: "row" or "column"
RenderStylestring"read"Render style: "read", "view", or "focused"
SchemaStylestring"table"Schema display: "table" or "tree"
BgColorstring"#fff"Background color
TextColorstring"#444"Text color
HeaderColorstring"#444444"Header color
PrimaryColorstring"#FF791A"Primary/accent color
HideInfoboolfalseHide the info section
HideHeaderboolfalseHide the header section
HideSearchboolfalseHide the search bar
HideAdvancedSearchboolfalseHide the advanced search bar
HideTryItboolfalseHide the "Try" feature
Logostring""Logo URL

Embedded Mode

Use rapidocemb for air-gapped deployments:

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

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

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