plugins: [pluginRedoc()]OpenAPI to Redoc documentation generator
@kubb/plugin-redoc
Generates a single-file HTML page from your OpenAPI spec with Redoc, rebuilt on every Kubb run so the docs match the spec your code comes from.
The Redoc plugin generates one Redoc HTML page with your OpenAPI spec embedded. Publish it to any static host without a build step.
Installation
kubb add plugin-redocbun add -d @kubb/plugin-redocpnpm add -D @kubb/plugin-redocnpm install --save-dev @kubb/plugin-redocyarn add -D @kubb/plugin-redockubb add installs the version the Kubb registry pins and adds pluginRedoc() to kubb.config.ts. It needs a kubb.config.ts, so run kubb init first in a new project.
Setup
No other plugins or packages are needed. The plugin needs an adapter that produces an OpenAPI 3 or Swagger 2 document, such as the default adapterOas. Without one it fails with KUBB_ADAPTER_REQUIRED.
Options worth knowing
| Option | Default | What it does |
|---|---|---|
output.path | 'docs.html' | Path of the HTML file, relative to the root output.path. End it with .html, because it names a file. |
The plugin has no other options.
Example
This config writes the page to src/gen/docs.html, titled with the spec's info.title.
import { defineConfig } from 'kubb/config'
import { pluginRedoc } from '@kubb/plugin-redoc'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen' },
plugins: [
pluginRedoc({ output: { path: 'docs.html' } }),
],
})src/
└── gen/
└── docs.htmlDependencies
No extension dependencies.
