v13.0
Web Component API Reference

RapiDoc API Specification

Comprehensive reference for every HTML attribute, JavaScript DOM method, custom lifecycle event, slot placeholder, and vendor extension supported by <rapi-doc>.

Config Options

HTML Attributes#

Declared directly on the <rapi-doc> web component element to customize styling, layout modes, feature visibility, routing, and authentication.

Spec & Content Attributes#9

Attribute NameDescription & Allowed ValuesDefault
URL of the OpenAPI specification file (JSON or YAML) to load and render.
(empty)
Allowed:
truefalse
Sorts tags in alphabetical order. When set to "false", preserves the tag order defined in the OpenAPI specification.
false
Allowed:
truefalse
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:
pathmethodsummarynone
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
Allowed:
truefalse
Shows tags that no operation uses, as long as they have a description, so a tag can hold a guide or concepts section (written in markdown) next to the operations. Each such tag gets a section and a sidebar link. When "false", tags without operations are left out, except those the spec lists in x-tagGroups, which show either way.
ⓘ This is a static initialization attribute. It will not have any effect if modified using JavaScript after the spec is rendered.
false
Which operations to show: a space- or comma-separated list of terms. An operation is shown when it matches any include term (every one is, without one) and no ! term. A term is an operationId (getPetById), a method and path (GET /pet/{petId}), a path for all its methods, a path glob (/pet/**; * is one segment, ** any number), tag:store, badge:Beta (an x-badges label) or deprecated; ! before a term leaves out what it matches (!badge:Internal). Shown operations keep the order of the first term they match, so a list of operationIds shows them in that order (unless sort-endpoints-by is set).
(empty)
match-paths#Deprecated
Allowed:
[REMOVED] Use filter-operations: a path glob (/pet/**), a method and path, or operationIds.
—
match-type#Deprecated
Allowed:
includesregex
[REMOVED] filter-operations matches exact terms and path globs, not substrings or regular expressions.
includes
Allowed:
[REMOVED] Use filter-operations="!badge:Beta".
—

Layout & Scrolling Attributes#4

Attribute NameDescription & Allowed ValuesDefault
Allowed:
readviewfocused
Controls the overall documentation presentation layout. Three distinct modes are supported:
  • view: Optimized for interactive exploration with collapsible operations | Example
  • read: Continuous narrative page layout, ideal for reading through API specifications from top to bottom | Example
  • focused: Displays a single endpoint at a time with a dedicated sidebar, ideal for large enterprise schemas | Example
read
Allowed:
rowcolumn
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: Any valid CSS height value (e.g. 400px, 50%, 60vh).
Controls the vertical height of the interactive response payload viewer.
400px
Allowed: A number of pixels (e.g. 96).
With auto-height="true", where the page scrolls instead of RapiDoc, this is the height of a sticky or fixed page header. Navigation scrolls a section to just below it, and the active navigation item ignores sections hidden under it. When not set, RapiDoc uses the scroll root's scroll-padding-top, so a page that already sets it needs no extra configuration.
(scroll-padding-top of the page)

Theme Attributes#4

Attribute NameDescription & Allowed ValuesDefault
Allowed:
embercarboncobaltjadeindigo(or custom hex color e.g. #2563eb)
Brand color preset, or a custom brand color as a hex code. Each preset defines a dark and a light palette.
ember
Allowed:
darklightsystemauto
Base color scheme mode. 'system' automatically matches the user's OS preference. 'auto' follows the host page: it reads the page's CSS color-scheme (for example :root[data-theme='light'] { color-scheme: light }, as Starlight sets it) and updates when the page switches theme; when the page declares none, it falls back to the OS preference.
dark
Allowed:
nonesmmdlgfull
Corner radius scale applied across cards, buttons, badges, inputs, and dialogs.
sm
Allowed:
smdefaultlg
Relative scale factor for typography and UI elements across the documentation portal.
default

Header & Sections Attributes#9

Attribute NameDescription & Allowed ValuesDefault
Allowed:
truefalse
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
Custom title text displayed on the top-left corner of the header.
(empty)
Allowed:
truefalse
Toggles visibility of the OpenAPI document info section (title, description, version, terms of service). Useful when embedding `` into an existing developer portal or knowledge base that already contains its own header.
true
Allowed:
truefalse
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:
truefalse
When set to false, disables the input field allowing users to load arbitrary external OpenAPI specification URLs.
true
Allowed:
truefalse
When set to false, hides the file picker allowing users to upload and preview local OpenAPI spec files (desktop viewports >768px).
true
Allowed:
truefalse
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

Schemas Attributes#7

Attribute NameDescription & Allowed ValuesDefault
Allowed:
treetable
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 (the default expands all levels).
99999
Allowed:
truefalse
Controls whether schema field constraints, validation rules, and descriptions are fully expanded by default or collapsed to a single line.
false
Allowed:
truefalse
Shows or hides the button allowing users to toggle between single-line summary and multi-line detailed schema property descriptions.
true
Allowed:
defaultnever
'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:
defaultnever
'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:
schemaexample
Selects which tab is active by default, and listed first, for request bodies, responses and object parameters: 'schema' (data contract model) or 'example' (sample JSON payload).
example

Try & Servers Attributes#7

Attribute NameDescription & Allowed ValuesDefault
Allowed:
truefalse
Enables the interactive "TRY" console allowing users to test live API calls directly from their browser.
true
Allowed:
truefalse
When set to true, generates and displays copyable cURL commands directly within the endpoint documentation prior to clicking "TRY".
false
Allowed:
truefalse
Pre-populates interactive request parameter inputs and request body fields using example values defined in the OpenAPI spec.
true
Allowed:
truefalse
Enables the dropdown allowing users to switch between target servers declared in the OpenAPI spec.
true
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)
Allowed:
omitsame-origininclude
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)

Authentication Attributes#8

Attribute NameDescription & Allowed ValuesDefault
Allowed:
truefalse
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:
truefalse
Keeps API keys, bearer tokens and OAuth access tokens in localStorage across page reloads; an OAuth token is dropped once it expires. Basic credentials and OAuth client secrets are never stored.
false
Name of the header or query parameter used when transmitting the API key in interactive console requests.
(empty)
Allowed:
headerquery
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)
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:
  • JSON String (recommended for HTML attributes):
    additional-authorize-params='{"launch": "xyz123", "prompt": "consent"}'
  • URL Query String:
    additional-authorize-params="launch=xyz123&prompt=consent"
  • JavaScript Object (via property):
    rapidocEl.additionalAuthorizeParams = { launch: 'xyz123', prompt: 'consent' };
(empty)
Custom parameters included in the POST request body sent to the OAuth2 token endpoint (e.g. custom proxy parameters, resource, audience).

Supported Formats:
  • JSON String (recommended for HTML attributes):
    additional-token-params='{"audience": "https://api.example.com", "resource": "urn:my:api"}'
  • URL-Encoded String:
    additional-token-params="audience=https%3A%2F%2Fapi.example.com"
  • JavaScript Object (via property):
    rapidocEl.additionalTokenParams = { audience: 'https://api.example.com' };
(empty)

Mock Server Attributes#5

Attribute NameDescription & Allowed ValuesDefault
Allowed:
truefalse
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
HTTP status code (or comma-separated list of codes, e.g. "200, 404, 500") to answer with, or a JSON map by operation ({ "POST /orders": "503, 200", "*": "200" }). Set it to an empty string to use the first 2xx response in the spec.
200
Allowed:
firstcyclerandom
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:
truefalse
Logs one line per answered request (method, path and status code) to the browser console.
false

MCP Attributes#2

Attribute NameDescription & Allowed ValuesDefault
Allowed:
truefalsenone
Enables Model Context Protocol (MCP) server export for AI agents. true renders an Export MCP Server button in the overview section that downloads a zip with the MCP manifest (manifest.json), a fixed runtime (runtime.js) and a stdio TypeScript server (server.ts). false, none or an empty value hides the button.
false
Custom name for the generated MCP server. Defaults to the API specification title.
(empty)
JavaScript API

DOM Methods#

Methods accessible directly on the <rapi-doc> DOM element instance (e.g. document.getElementById('doc').loadSpec(...)) for seamless programmatic interaction.

Programmatic Control Example
// 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 NameDescription & Usage
Programmatically loads a new OpenAPI specification. Accepts either a string URL or a valid in-memory JSON/JavaScript spec object. The download and view buttons and the header's spec URL box follow the spec loaded: its URL, or none for a spec object (the spec download buttons are then hidden).
Connects a sidebar rendered outside the component (for example the static HTML from getNavBarHtml in @rapidoc/prerender) to this element: clicks navigate with scrollToPath, the active item follows nav-active-change, and the filter box filters the sidebar. sidebar is an element or a CSS selector; options accepts activeClass (default active) and updateHistory (default true). Returns a function that removes the bindings.
Programmatically scrolls the viewport to focus on a specific endpoint section. The path argument is the operation's element ID (e.g., login-user) or its method + path anchor (e.g., get-user-login; the older get-/user/login format also works).
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, Bearer Token or OAuth security scheme. Optional options.note says where the key came from (for example the reader's sign-in); the Authentication section shows it in place of that scheme's form, with a link to open the form. Changing or removing the key drops the note.
<script>
  const rapidocEl = document.getElementById('the-doc');
  rapidocEl.addEventListener('spec-loaded', () => {
    rapidocEl.setApiKey('oauth2', 'Bearer ' + token, { note: 'Using your sign-in (ann@example.com).' });
  });
</script>
Programmatically switches the active target API server URL.
<html>
  ...
  <rapi-doc id="the-doc" spec-url="https://.../spec.yaml"></rapi-doc>
  <script>
    window.addEventListener('DOMContentLoaded', () => {
      const rapidocEl = document.getElementById('the-doc');
      rapidocEl.addEventListener('spec-loaded', () => {
        rapidocEl.setApiServer(window.location.origin + "/api");
      });
    });
  </script>
  ...
</html>
Builds the MCP manifest and the exported project in memory. Returns { manifest, files, budget, hostConfig }: manifest is the plain JSON description of the server (one tool per operation with a JSON Schema inputSchema, MCP annotations and the operation the runtime executes), files maps every file of the zip to its text (manifest.json, server.ts, runtime.js, package.json, README.md, claude_desktop_config.json), budget is the token diagnostics and hostConfig the Claude Desktop / Cursor config JSON. options: serverName, includeInternal, includeDeprecated, includeOperations (false: only the workflow tools of a paired <rapi-flow>).
Downloads the exported project as <server-name>-mcp.zip (<server-name>-workflows-mcp.zip with includeOperations: false). Same options as generateMcpServer.
Returns prompt token overhead diagnostics for the current OpenAPI specification: { totalTools, totalResources, estimatedTokens, consequentialCount, warnings }, where consequentialCount is the number of tools that are not read-only and warnings lists context footprint warnings (over 30 tools or 5,000 tokens).
Runtime Hooks

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.

Event Interceptor Example
// 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 NameDescription & 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:
 rapidocEl.addEventListener('before-try', (e) => {
  if (e.detail.request.method === 'POST') {
    e.detail.request.headers.append('X-Tenant-ID', 'corp-acme-123');
  }
}); 
Example: Append query parameters to all GET requests:
 rapidocEl.addEventListener('before-try', (e) => {
  if (e.detail.request.method === 'GET') {
    const url = new URL(e.detail.request.url);
    url.searchParams.append('client_version', '2.4.0');
    e.detail.request.url = url.toString();
  }
}); 
Example: Abort specific requests conditionally:
 rapidocEl.addEventListener('before-try', (e) => {
  if (e.detail.request.method === 'DELETE') {
    alert('DELETE operations are disabled in this sandbox environment.');
    e.detail.controller.abort();
  }
}); 
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:
 rapidocEl.addEventListener('before-authorize', (e) => {
  e.detail.authParams.set('launch', 'xyz123');
}); 
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:
 rapidocEl.addEventListener('before-token-request', (e) => {
  e.detail.params.set('audience', 'https://api.mycompany.com');
  e.detail.headers.set('X-Client-Version', '1.0.0');
}); 
Component Slots

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.

Slot Injection Example
<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 NamePlacement & Description
Any standard markup placed directly inside the `` tag renders immediately below the header bar and above the specification info overview.
Custom HTML elements rendered in the top header bar following the spec URL input controls.
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-).
OpenAPI Spec Extensions

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 NameDescription & 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 filter-operations="!badge:Internal" to filter out restricted or internal APIs from public documentation.
Top-level vendor extension defining a 3-tier navigation hierarchy (compatible with ReDoc / Zudoku). Organizes API tags into higher-level groups in the sidebar navigation, read mode sections, and view mode accordions. Takes an array of group objects, each with name, optional description, and a tags list of tag names.
Alternative kebab-case syntax for x-tagGroups.
Allowed:
truefalse
Controls initial expansion state. Can be configured on individual tags or on top-level x-tagGroups items to start sections expanded or collapsed.
Allowed:
yesno
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:
truefalse
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:
request-bodyheader
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:
truefalse
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:
 components:
  securitySchemes:
    oauth-flow:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://auth.example.com/oauth2/authorize
          tokenUrl: https://auth.example.com/oauth2/token
          x-authorize-params:
            launch: xyz123
            prompt: consent
            audience: https://api.mycompany.com
          scopes:
            read: Read access
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:
 components:
  securitySchemes:
    oauth-flow:
      type: oauth2
      flows:
        authorizationCode:
          authorizationUrl: https://auth.example.com/oauth2/authorize
          tokenUrl: https://auth.example.com/oauth2/token
          x-token-params:
            audience: https://api.mycompany.com
            resource: urn:my:resource:server
          scopes:
            read: Read access