Quickstart
-
Create an HTML file that loads RapiDoc and points
<rapi-doc>at your spec:index.html <!doctype html><html lang="en"><head><meta charset="utf-8" /><script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script><style>body { margin: 0; }rapi-doc { height: 100vh; }</style></head><body><rapi-doc spec-url="https://petstore.swagger.io/v2/swagger.json"></rapi-doc></body></html> -
Open it in a browser. You get navigation, search, schemas and a Try console that calls the API.
-
Replace
spec-urlwith the URL of your own OpenAPI 3.x or Swagger 2.0 file, in JSON or YAML. If the spec is on another domain, that server must allow cross-origin requests (see Loading Your Spec).
Install from npm
Section titled “Install from npm”With a bundler, install the package and import it once in your entry file. The import registers <rapi-doc>; use it in your markup as above.
npm install rapidocpnpm add rapidocyarn add rapidocimport 'rapidoc';For production, pin a version (https://unpkg.com/rapidoc@12/dist/rapidoc-min.js) or serve the file from your own site.
Make it yours
Section titled “Make it yours”A few attributes cover most needs:
<rapi-doc spec-url="/openapi.yaml" theme="cobalt" color-scheme="light" render-style="view" allow-try="false"></rapi-doc>| Attribute | Values | Default |
|---|---|---|
theme |
ember, carbon, cobalt, jade, indigo, or a #hex brand color |
ember |
color-scheme |
dark, light, system |
dark |
render-style |
read (one long page), view (expandable sections), focused (one operation at a time) |
read |
show-header |
true, false |
true |
allow-try |
true, false: show or hide the Try console |
true |
Every attribute, method, event and slot is listed in the API reference.
Next steps
Section titled “Next steps”- Framework Integration: React, Next.js, Vue and Angular.
- Theming Overview: colors, fonts, radius and scale.
- OAuth 2.0: let readers sign in before they press Try.
- Packages: everything else in the RapiDoc family.