Command Line
@rapidoc/cli gives you the rapidoc command. It builds and runs developer portals, and the commands on this page also work on plain OpenAPI files, wherever you use <rapi-doc>:
previewshows a spec as you edit it.validateandlintcheck it.bundlejoins a spec split over several files into one.mockserves its API with example responses.mcpturns it into tools for AI agents.
npm install -D @rapidoc/clinpx rapidoc --help # every commandnpx rapidoc validate --help # one command's options and examplesPreview a spec
Section titled “Preview a spec”npx rapidoc preview openapi.yaml --openShows the spec in <rapi-doc> on http://localhost:4000 and reloads it whenever a file in its folder changes, so you can edit the YAML and watch the page. Relative $refs to other files work. --theme picks a <rapi-doc> theme; a URL works too (npx rapidoc preview https://example.com/openapi.json), without reloading.
Validate a spec
Section titled “Validate a spec”npx rapidoc validate openapi.yamlnpx rapidoc validate https://example.com/openapi.jsonrapidoc validate checks a spec strictly against the OpenAPI Specification (2.0, 3.0, 3.1 and 3.2): required fields such as info.version, types, path parameters that are used but not defined, and $refs that point to nothing. Files reached through a relative $ref are checked too. Each error names the file, line and column:
🔍 openapi.yaml: openapi.yaml ❌ 1 error(s): openapi.yaml:3:1 must have required property 'version' (#/info)| Option | Meaning |
|---|---|
--format pretty | json | sarif |
json for scripts, sarif for GitHub code scanning (problems shown on the pull request). |
--strict |
Fail on warnings too. |
--remote |
Also fetch remote $refs. |
It exits with code 1 when the spec has errors, so it can guard a pull request:
# in a job's steps:- run: npx rapidoc validate openapi.yamlLint a spec
Section titled “Lint a spec”npx rapidoc lint openapi.yamlnpx rapidoc lint openapi.yaml --rule operation-description=warn --strictA valid spec can still make a poor reference page. rapidoc lint runs validate’s check and then rules for what <rapi-doc>, Try and MCP tools need: an operationId on every operation (stable anchors and tool names), unique and URL-safe; a summary (the sidebar label); tags declared in the top-level list; a success response; a security requirement on write operations; an example on request and response bodies (Try’s sample body); no unused components; no example.com servers. Each finding comes with file:line:col and the rule name, in the same pretty, JSON or SARIF output as validate. Most rules default to warn, so a first run doesn’t fail CI; --strict makes warnings fail, --rule name=off turns one off, and --rules lists them all.
Bundle a spec split over files
Section titled “Bundle a spec split over files”npx rapidoc bundle openapi.yaml -o dist/openapi.jsonnpx rapidoc bundle openapi.yaml --dereference > flat.yamlrapidoc bundle writes a spec and every file its $refs reach as one document, for tools that can’t follow $refs across files. A $ref to another file becomes a component (./schemas/Order.yaml → #/components/schemas/Order, holding a copy; definitions in Swagger 2.0), named after the file or the pointer’s last part, and in-file $refs stay. --dereference inlines everything instead, and stops on a recursive schema. The result is validated before it’s written (--no-validate skips that); -o picks JSON or YAML by the extension, and without it the document goes to stdout.
Mock the API
Section titled “Mock the API”npx rapidoc mock openapi.yaml # http://localhost:4010/openapinpx rapidoc mock ./specs --port 4011 # every OpenAPI file in the folderrapidoc mock answers every operation of the spec over HTTP, from its examples or with generated data. It validates requests and can check OAuth tokens against your OpenID Connect issuer. It needs @rapidoc/mock. See Mock Server for the options, and the overview for how it compares with the in-browser mock.
Turn it into an MCP server
Section titled “Turn it into an MCP server”npx rapidoc mcp export openapi.yaml --out-dir orders-mcp # the server projectnpx rapidoc mcp serve openapi.yaml # run it over stdio, no filesmcp export writes the same project as <rapi-doc>’s Export MCP Server button. mcp serve runs it directly, so an agent’s config can start it with npx rapidoc mcp serve <spec> (it needs @modelcontextprotocol/sdk installed). Credentials come from the environment, one variable per security scheme; --base-url points the calls at rapidoc mock, and --arazzo adds workflows as tools.
Everything else
Section titled “Everything else”rapidoc doctor checks your setup (Node, package versions) and prints a report for bug reports. The other commands (init, dev, build, serve, migrate) create and run a developer portal: OpenAPI references next to Markdown and Markdoc guides, with search and optional single sign-on. The full reference, with every option, is in the RapiDoc Portal docs.
In a terminal, rapidoc asks for what the options don’t say and shows a menu when run alone; piped, in CI or with --yes it never asks. Exit codes: 0 success, 1 problems in the input, 2 a wrong command line. rapidoc completion zsh|bash|fish prints a completion script for commands, options and their values.