Skip to main content

ApiUiFactory

Renders a self-contained HTML page presenting an interactive API reference UI directly from an OPRA ApiDocument — no OpenAPI conversion involved.

import { ApiUiFactory } from '@opra/api-ui';

render(document, options?)​

static render(
document: ApiDocument,
options?: ApiUiOptions,
): string

Returns a complete, self-contained HTML string. Every controller, operation, and named type is embedded in the page; referenced documents (from document.references) are embedded alongside the root so the document switcher in the header needs no further network round-trips.

ParameterTypeDescription
documentApiDocumentThe OPRA API document to render.
optionsApiUiOptionsOptional rendering options. See ApiUiOptions.

Example​

import { ApiUiFactory } from '@opra/api-ui';

const html = ApiUiFactory.render(apiDocument, {
pageTitle: 'My API Reference',
theme: 'dark',
});

// Serve or write to a file
res.setHeader('Content-Type', 'text/html');
res.end(html);

See also​