Skip to content
v12.2
GitHub

RapiDoc Mini

<rapi-doc> is a whole API reference with navigation and search. <rapi-doc-mini> shows only the operations you pick, with their parameters, schemas and Try console, so you can put a working endpoint in the middle of a tutorial, changelog or wiki page without an <iframe>. It is in the same bundle as <rapi-doc>.

Point spec-url at your spec and choose operations with match-paths:

<script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
<rapi-doc-mini
spec-url="https://petstore.swagger.io/v2/swagger.json"
match-paths="get /pet/{petId}"
></rapi-doc-mini>

match-paths is compared with "<method> <path>" of every operation, ignoring case. By default (match-type="includes") an operation matches when that text contains the value, so post /user also matches post /user/createWithList. For an exact match, use a regular expression:

<rapi-doc-mini
spec-url="https://petstore.swagger.io/v2/swagger.json"
match-paths="^post /user$"
match-type="regex"
></rapi-doc-mini>
<rapi-doc-mini
spec-url="/specs/reqres.yaml"
match-paths="^get /users/\{userId\}$|^post /users$"
match-type="regex"
schema-style="table"
></rapi-doc-mini>

If the spec can’t be loaded, the element renders nothing and logs the error to the browser console.

All attributes can be changed at runtime with setAttribute.

Attribute Values Default Meaning
spec-url URL The OpenAPI spec, JSON or YAML.
match-paths text Which operations to show (see above).
match-type includes, regex includes How match-paths is compared.
remove-endpoints-with-badge-label-as text Hides operations that have an x-badges label with this text.
sort-endpoints-by path, method, summary path Order of the operations shown.
Attribute Values Default Meaning
paths-expanded true, false false Shows operations open instead of collapsed.
layout row, column row Request and response side by side, or one above the other.
show-summary-when-collapsed true, false true Shows the summary on a collapsed operation.
schema-style tree, table tree How schemas are drawn.
schema-expand-level number 99999 How many schema levels start expanded.
schema-description-expanded true, false false Shows schema descriptions in full.
default-schema-tab example, schema example The tab selected and listed first for request bodies, responses and object parameters.
response-area-height CSS height 300px Height of the response panel.
Attribute Values Default Meaning
allow-try true, false true Shows the Try console.
show-curl-before-try true, false false Shows the curl command before the request is sent.
fill-request-fields-with-example true, false true Pre-fills request fields with examples.
server-url URL The server Try sends requests to, instead of the spec’s.
default-api-server URL The spec server selected first.
fetch-credentials omit, same-origin, include The credentials mode of Try requests.
api-key-name text Name of the header, query parameter or cookie that carries the key.
api-key-location header, query header Where the key is sent.
api-key-value text The key.
persist-auth true, false false Keeps API keys, bearer tokens and OAuth access tokens across page loads (never Basic credentials).
oauth-receiver URL oauth-receiver.html The OAuth callback page; see OAuth 2.0.
additional-authorize-params, additional-token-params JSON or query string Extra OAuth parameters.
Attribute Values Default
theme ember, carbon, cobalt, jade, indigo, or a #hex color ember
color-scheme dark, light, system, auto dark
radius none, sm, md, lg, full sm
scale sm, default, lg default
primary-color #hex: replaces the theme’s accent

<rapi-doc-mini> takes the same mock-server, mock-server-status-code, mock-server-status-strategy, mock-server-delay and mock-server-log attributes as <rapi-doc>; see In-Browser Mock. Only the operations it shows are mocked.

Feature / Goal<rapi-doc><rapi-doc-mini>
Best forA complete API reference, on its own pageOne or a few endpoints inside a blog post, tutorial or changelog
Navigation sidebar and searchYesNo
URL hash routingYes (update-route)No: never changes the page URL
Try consoleYesYes
SizingFills the height you give it, usually the viewportGrows with its content inside any container
Render modesread, view and focusedOne: the matched operations