RapiDoc API Specification
Comprehensive reference for every HTML attribute, JavaScript DOM method, custom lifecycle event, slot placeholder, and vendor extension supported by <rapi-doc>.
HTML Attributes#
Declared directly on the <rapi-doc> web component element to customize styling, layout modes, feature visibility, routing, and authentication.
General Attributes#10
| Attribute Name | Description & Allowed Values | Default |
|---|---|---|
URL of the OpenAPI specification file (JSON or YAML) to load and render. | (empty) | |
Allowed: When set to "true", automatically updates the browser's URL address hash as the user scrolls through or clicks on different sections. | true | |
Custom prefix prepended to route hashes to integrate seamlessly with third-party routers (e.g. | # | |
Allowed: Sorts tags in alphabetical order. When set to "false", preserves the tag order defined in the OpenAPI specification.
| false | |
Allowed: Sorts component schemas alphabetically. When set to "false", preserves the order defined in the spec. Note: Only has an effect if render-style="focused" and show-components="true".
| false | |
Allowed: Sorts endpoints within each tag group by path, HTTP method, or summary. 'none' leaves the sort order unmodified. ⓘ This is a static initialization attribute. It will not have any effect if modified using JavaScript after the spec is rendered. | path | |
Custom title text displayed on the top-left corner of the header. | (empty) | |
Target endpoint location to navigate to automatically after the specification finishes loading. Must be provided in the format of {method}-{path} (e.g., to focus on GET /user/login, provide get-/user/login).
| (empty) | |
Allowed: Pre-populates interactive request parameter inputs and request body fields using example values defined in the OpenAPI spec. | true | |
Allowed: Persists authenticated user credentials (API keys, tokens) in localStorage across browser sessions and page reloads. | false |
UI Colors and Fonts Attributes#5
| Attribute Name | Description & Allowed Values | Default |
|---|---|---|
Allowed: Semantic color theme preset or custom brand color hex/css value. Pre-built presets match modern shadcn/ui color tokens.
| amber | |
Allowed: Base color scheme mode. 'system' automatically matches the user's OS preference. | dark | |
Allowed: Corner radius scale applied across cards, buttons, badges, inputs, and dialogs. | sm | |
Allowed: Relative scale factor for typography and UI elements across the documentation portal. | default | |
Allowed: Automatically loads default Open Sans font from Google Fonts CDN. Set to "false" for air-gapped, offline, or enterprise intranet environments. | true |
UI Layout and Placement Attributes#3
| Attribute Name | Description & Allowed Values | Default |
|---|---|---|
Allowed: Controls the multi-column orientation of request parameters and response panels on desktop screens (>768px). In 'row' layout, request and response sections sit side-by-side; in 'column' layout, they stack vertically. Defaults to 'column' when render-style is 'read' or 'focused', and 'row' when render-style is 'view'.
| column (read, focused) / row (view) | |
Allowed: Controls the overall documentation presentation layout. Three distinct modes are supported:
| read | |
Allowed: Any valid CSS height value (e.g. 400px, 50%, 60vh). Controls the vertical height of the interactive response payload viewer. | 300px |
Hide and Show Attributes#17
| Attribute Name | Description & Allowed Values | Default |
|---|---|---|
Allowed: Toggles visibility of the OpenAPI document info section (title, description, version, terms of service). Useful when embedding ` | true | |
Allowed: Extracts Markdown headings (H1 and H2) from the specification's info description and adds them to the sidebar navigation menu (read mode only).
| false | |
Filters and renders only endpoints matching a specific substring or regular expression, enabling audience segmentation (e.g., showing only public endpoints). The matching strategy is configured via match-type.
| (empty) | |
Allowed: Defines whether match-paths filters by simple substring inclusion or regular expression pattern matching. | includes | |
Comma-separated badge labels to exclude from the rendered documentation. Works in tandem with the x-badges vendor extension to filter out internal, beta, or deprecated endpoints from customer-facing views.
| — | |
Allowed: Toggles the components section (schemas, responses, examples, request bodies, headers, security schemes) in both the document body and sidebar menu (available in focused render-style).
| false | |
Allowed: Toggles the top navigation header bar. Set to false to prevent users from loading alternative spec URLs or to seamlessly embed inside existing layouts.
| true | |
Allowed: Controls the display of interactive authentication controls (HTTP Basic, Bearer Token, API Key, OAuth2). Disable to hide authentication dialogs when using hardcoded or pre-authenticated API keys.
| true | |
Allowed: When set to false, disables the input field allowing users to load arbitrary external OpenAPI specification URLs. | true | |
Allowed: When set to false, hides the file picker allowing users to upload and preview local OpenAPI spec files (desktop viewports >768px). | true | |
Allowed: When set to true, displays convenient buttons in the overview section to download the raw OpenAPI specification file or view it in a new tab. | false | |
Allowed: Enables the instant search and filtering input in the navigation sidebar. | true | |
Allowed: Enables deep multi-property search modal, indexing paths, descriptions, parameter names, and response schemas. | true | |
Allowed: Enables the interactive "TRY" console allowing users to test live API calls directly from their browser. | true | |
Allowed: When set to true, generates and displays copyable cURL commands directly within the endpoint documentation prior to clicking "TRY". | false | |
Allowed: Enables the dropdown allowing users to switch between target servers declared in the OpenAPI spec. | true | |
Allowed: Shows or hides the button allowing users to toggle between single-line summary and multi-line detailed schema property descriptions. | true |
Schema Section Attributes#6
| Attribute Name | Description & Allowed Values | Default |
|---|---|---|
Allowed: Controls the visual representation of complex JSON schemas in request and response panels. 'tree' provides an interactive collapsible tree view; 'table' renders structured tabular rows. | tree | |
Initial depth level for auto-expanding complex nested schema properties and sub-objects (default 999 expands all levels). | 999 | |
Allowed: Controls whether schema field constraints, validation rules, and descriptions are fully expanded by default or collapsed to a single line.
| false | |
Allowed: 'default' hides read-only properties in request bodies while displaying them in response models and webhook callbacks. Set to 'never' to always display read-only fields across all payloads. Note: This does not affect example generation.
| default | |
Allowed: 'default' hides write-only properties in response bodies while displaying them in request payloads. Set to 'never' to always display write-only fields across all payloads. Note: This does not affect example generation.
| default | |
Allowed: Selects which tab is active by default for request and response payloads: 'schema' (data contract model) or 'example' (sample JSON payload).
| schema |
API Server Attributes#9
| Attribute Name | Description & Allowed Values | Default |
|---|---|---|
Custom API server base URL. Overrides the servers array defined in the OpenAPI specification. Particularly useful when sharing a single spec across development, staging, and production environments.
| (empty) | |
Selects which server URL from the spec's servers list should be selected by default.
| (empty) | |
Name of the header or query parameter used when transmitting the API key in interactive console requests. | (empty) | |
Allowed: Specifies whether the API key is passed as an HTTP request header or query parameter. | header | |
Pre-configured API key value sent during interactive console requests. Can also be set or overwritten directly in the UI. | (empty) | |
Allowed: Configures credentials mode for cross-origin browser Fetch requests as defined in the Fetch Standard, enabling transmission of cookies and Authorization headers in CORS requests.
| (empty) | |
Relative or absolute path to the OAuth receiver HTML file for handling authorization redirection callbacks.
| oauth-receiver.html | |
Custom query parameters appended to the OAuth2 authorization URL query string (e.g. proxy launch tokens, prompt, audience). Supported Formats:
| (empty) | |
Custom parameters included in the POST request body sent to the OAuth2 token endpoint (e.g. custom proxy parameters, resource, audience). Supported Formats:
| (empty) |
Mock Server Attributes#5
| Attribute Name | Description & Allowed Values | Default |
|---|---|---|
Allowed: Enables the built-in, zero-dependency in-browser mock server. Transparently intercepts outgoing network requests (both RapiDoc's Try console and host application fetch/XHR calls) and serves mock responses based on OpenAPI examples or generated from schemas.
| false | |
Preferred HTTP status code (or comma-separated list of codes, e.g. "200, 404, 500") to simulate. If left empty, the mock server automatically picks the first available 2xx response in the spec.
| (empty) | |
Allowed: Selection strategy when multiple status codes are specified in mock-server-status-code. 'first' always returns the first code; 'cycle' round-robins sequentially per endpoint (ideal for testing retry and backoff logic); 'random' selects a code randomly for chaos and resilience testing.
| first | |
Simulated network latency in milliseconds before resolving mock responses. Useful for testing client loading spinners and optimistic UI updates.
| — | |
Allowed: Logs intercepted requests, matched OpenAPI routes, and synthesized status codes to the browser DevTools console.
| true |
DOM Methods#
Methods accessible directly on the <rapi-doc> DOM element instance (e.g. document.getElementById('doc').loadSpec(...)) for seamless programmatic interaction.
// Programmatically control RapiDoc from your web app
const rapidoc = document.getElementById('the-doc');
// Switch API server on runtime event
rapidoc.setApiServer('https://staging-api.example.com/v1');
// Programmatically scroll to and open a specific endpoint
rapidoc.scrollToPath('get-/users/{id}');
// Set credentials dynamically
rapidoc.setApiKey('api_key_header', 'sk_live_9482910481029');| Method Name | Description & Usage |
|---|---|
Programmatically loads a new OpenAPI specification. Accepts either a string URL or a valid in-memory JSON/JavaScript spec object.
| |
Programmatically scrolls the viewport to focus on a specific endpoint section. The path argument must be formatted as {method}-{path} (e.g., get-/user/login).
| |
Programmatically supplies username and password credentials for an HTTP Basic security scheme declared in the spec.
| |
Programmatically provides the token or key for a declared API Key or Bearer Token security scheme.
| |
Programmatically switches the active target API server URL.
|
Lifecycle & Console Events#
Standard CustomEvents dispatched by <rapi-doc> that allow you to intercept request pipelines, inject authorization headers, capture metrics, and respond to UI state changes.
// Intercept requests and add authentication or telemetry
const rapidocEl = document.getElementById('the-doc');
// Fires before the HTTP request is dispatched
rapidocEl.addEventListener('before-try', (e) => {
if (e.detail.request.method === 'POST') {
e.detail.request.headers.append('X-Tenant-ID', 'corp-acme-123');
}
});
// Fires when API server selection changes
rapidocEl.addEventListener('api-server-change', (e) => {
console.log('Selected target server:', e.detail.selectedServer);
});| Event Name | Description & Payload |
|---|---|
Dispatched before rendering starts. Provides the parsed OpenAPI specification object via e.detail.spec, allowing programmatic modifications before the UI tree is built.
| |
Dispatched after the OpenAPI specification has been fully fetched, parsed, resolved, and rendered into the DOM. Provides the resolved spec object in e.detail.
| |
Dispatched when a user clicks "TRY" before the network request is initiated. Provides a mutable Request-like object via e.detail.request to append headers, rewrite parameters, or modify payloads, along with an AbortController via e.detail.controller to abort requests conditionally. Example: Append custom authorization headers before sending: Example: Append query parameters to all GET requests: Example: Abort specific requests conditionally:
| |
Dispatched after a try request completes. Provides e.detail.request and e.detail.response. In the event of a network or protocol error, provides request and error objects.
| |
Dispatched when an in-flight API try request is aborted by the user or programmatically via AbortController. | |
Dispatched when the active target API server is modified in the dropdown. | |
Dispatched immediately before opening the OAuth authorization popup window. Provides e.detail.securitySchemeId, e.detail.flowType, e.detail.authUrl, and mutable e.detail.authParams (URLSearchParams). Calling e.preventDefault() cancels opening the authorization window. Example: Dynamically inject a launch token or proxy parameter:
| |
Dispatched immediately before sending the POST request to the OAuth2 token endpoint. Provides e.detail.securitySchemeId, e.detail.grantType, e.detail.tokenUrl, mutable e.detail.params (URLSearchParams), e.detail.headers (Headers), and mutable e.detail.request. Calling e.preventDefault() cancels the token request. Example: Add a custom token audience or header:
|
HTML Template Slots#
Standard Web Component slots that enable embedding your custom HTML, logos, corporate banners, and notices directly at specific locations within the RapiDoc UI canvas.
<rapi-doc spec-url="https://petstore.swagger.io/v2/swagger.json">
<!-- Default slot: Renders custom banner directly below top navigation -->
<div class="custom-hero">
<h1>Enterprise API Portal</h1>
</div>
<!-- Named slot: Custom logo inside the sidebar -->
<img slot="nav-logo" src="/brand/logo.svg" alt="Company Logo" width="36" height="36" />
<!-- Named slot: Custom notice above authentication panel -->
<div slot="auth" class="auth-notice">
<p>Please obtain API tokens from the Internal Developer Console.</p>
</div>
</rapi-doc>| Slot Name | Placement & Description |
|---|---|
Any standard markup placed directly inside the ` | |
Custom HTML or image markup to replace the default brand logo in the top header bar. | |
Custom HTML elements rendered in the top header bar following the spec URL input controls. | |
Custom HTML elements rendered at the bottom of the documentation canvas. | |
Custom image or branding markup placed at the top of the sidebar navigation panel (available in read mode). | |
Custom HTML rendered inside the overview section at the top of the document. Link directly to this anchor using #overview.
| |
Custom HTML rendered inside the server configuration section located under the overview container. Link directly using #servers.
| |
Custom HTML rendered inside the authentication controls panel under the overview section. Link directly using #auth.
| |
Custom HTML displayed directly above the operations list. Use this slot to provide global announcements, common headers, or usage instructions applicable across all API calls. Link directly using #operations-top.
| |
Inserts custom HTML content underneath a specific tag grouping identified by tag name. | |
Inserts custom HTML into a specific endpoint section. Identified by {method}-{path}, where special characters such as brackets, spaces, and hashes are replaced by hyphens (e.g. get-/pet/-petId-).
|
Supported Vendor Extensions (x-*)#
OpenAPI vendor extension properties (x-code-sample, x-badges, x-client-id, etc.) that you can place in your OpenAPI YAML/JSON to enrich documentation views.
| Extension Name | Description & Allowed Values |
|---|---|
Provides multi-language code snippets (cURL, Python, JavaScript, Go, etc.) for an endpoint. | |
Alternative camelCase syntax for x-code-sample. Provides multi-language code snippets for an endpoint. | |
Annotates endpoints with short, color-coded badges (e.g., "Internal", "Beta", "v2"). Combine with the remove-endpoints-with-badge-label-as attribute to filter out restricted or internal APIs from public documentation.
| |
Controls whether endpoints grouped under a tag start expanded or collapsed (applies in view and focused render styles).
| |
Allowed: Specifies whether a parameter's example value should be automatically populated in the interactive console input. To configure this behavior globally for all parameters, see fill-request-fields-with-example.
| |
Allowed: Specifies whether parameter example values should be visibly rendered on the documentation card. | |
Pre-fills the OAuth2 client ID in authentication modals. | |
Pre-fills the OAuth2 client secret in authentication modals. | |
Pre-fills default OAuth2 permission scopes in authentication modals. | |
Allowed: Defines whether client credentials (client_id / client_secret) are sent via request body or HTTP Authorization header (request-body or header). Default is request-body. | |
Restricts the client authentication options available in the UI dropdown (e.g. ["request-body", "header"]). | |
Allowed: When set to "true", enforces Proof Key for Code Exchange (PKCE) flow and prevents client secrets from being transmitted from the browser. | |
Object or query string defining custom parameters appended to the OAuth2 authorizationUrl query string (e.g. proxy launch tokens, prompt, audience). Supported at both security scheme and individual flow levels. Example:
| |
Object or form parameters sent in the POST request body to the OAuth2 tokenUrl (e.g. custom proxy fields, resource, audience). Supported at both security scheme and individual flow levels. Example:
|
