RapiDocv11.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.

General Attributes#10

Attribute NameDescription & Allowed ValuesDefault
URL of the OpenAPI specification file (JSON or YAML) to load and render.
(empty)
Allowed:
truefalse
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:
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
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:
truefalse
Pre-populates interactive request parameter inputs and request body fields using example values defined in the OpenAPI spec.
true
Allowed:
truefalse
Persists authenticated user credentials (API keys, tokens) in localStorage across browser sessions and page reloads.
false

UI Colors and Fonts Attributes#5

Attribute NameDescription & Allowed ValuesDefault
Allowed:
ambergraphiteslateemeraldvioletroseblue(or custom hex color e.g. #2563eb)
Semantic color theme preset or custom brand color hex/css value. Pre-built presets match modern shadcn/ui color tokens.
amber
Allowed:
darklightsystem
Base color scheme mode. 'system' automatically matches the user's 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
Allowed:
truefalse
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 NameDescription & Allowed ValuesDefault
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:
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: 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 NameDescription & Allowed ValuesDefault
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
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:
includesregex
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:
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
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:
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
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
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
Enables the dropdown allowing users to switch between target servers declared in the OpenAPI spec.
true
Allowed:
truefalse
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 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 (default 999 expands all levels).
999
Allowed:
truefalse
Controls whether schema field constraints, validation rules, and descriptions are fully expanded by default or collapsed to a single line.
false
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 for request and response payloads: 'schema' (data contract model) or 'example' (sample JSON payload).
schema

API Server Attributes#9

Attribute NameDescription & Allowed ValuesDefault
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:
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)
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)
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
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:
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 intercepted requests, matched OpenAPI routes, and synthesized status codes to the browser DevTools console.
true
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.
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.
<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>
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 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:
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