Quickstart
Build one HTML file that shows RapiDoc’s interactive reference for an OpenAPI spec. You need a browser and an internet connection. To use a spec file from your computer in step 3, you also need a local web server, such as npx serve, which needs Node.js.
-
Create an HTML file that loads RapiDoc and points
<rapi-doc>at the sample Petstore 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>rapi-doc { height: 100vh; }</style></head><body><rapi-doc spec-url="https://rapidocui.com/specs/petstore.yaml"></rapi-doc></body></html> -
Open it in a browser. You get navigation, search, schemas and a Try console that sends requests to the Petstore’s public server,
petstore3.swagger.io. -
Point
spec-urlat your own spec, an OpenAPI 3.x or Swagger 2.0 file in JSON or YAML, and reload: your API’s operations replace the Petstore’s. For a spec on a server, use its URL. For a file, put it next toindex.html, runnpx servein that folder, open the address it prints and setspec-url="openapi.yaml"(your file’s name).
Sizing
<rapi-doc> fills the height you give it. Set a height (here 100vh) and keep its default display: flex: with display: block the bottom of the content is cut off.
For production, pin a major version (https://unpkg.com/rapidoc@14/dist/rapidoc-min.js), so a new major version can’t change attributes under you, or serve the file from your own site.
Troubleshooting
Section titled “Troubleshooting”| What you see | What to do |
|---|---|
| A spec on another domain doesn’t load | That server must allow cross-origin requests: see Loading Your Spec. |
| A spec file next to the page doesn’t load | Browsers block a page opened from disk (file://) from reading other files. Run npx serve in the folder, open the address it prints, and use spec-url="openapi.yaml" (your file’s name). |
| Try fails with a network error | Your API must allow cross-origin requests from the page, including the Authorization header (or your API key’s header). |
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. With server rendering (Next.js, Nuxt, SvelteKit), import it in the browser only. See Front-End Frameworks.
npm install rapidocpnpm add rapidocyarn add rapidocimport 'rapidoc';Without a CDN
Section titled “Without a CDN”To serve everything yourself, on an intranet or an air-gapped network, copy the bundle out of the npm package. RapiDoc then loads nothing from a third-party host; requests go to your spec’s URL and the servers it names.
In index.html, set the script’s src to rapidoc-min.js and spec-url to openapi.yaml. Then put the page, your spec and the bundle in one folder, here public/:
npm install rapidocmkdir -p publiccp node_modules/rapidoc/dist/rapidoc-min.js* public/ # the bundle and its license noticescp index.html openapi.yaml public/ # your page and your specAny web server can serve the folder; in a container:
FROM nginx:alpineCOPY public/ /usr/share/nginx/html/Next steps
Section titled “Next steps”- Attributes: every attribute, such as
theme,color-scheme,render-styleandallow-try, with links to methods, events and slots. - Front-End Frameworks: React and Next.js, Vue and Nuxt, Angular, Svelte.
- Integrations: serving the reference from your server framework or documentation site.
- Theming Overview: colors, fonts, radius and scale.
- OAuth 2.0: let readers sign in before they press Try.
- Common Tasks: how to do the things most sites need, and where each is explained.
- Examples: every feature running, with the code behind it.
- Packages: everything else in the RapiDoc family.