Generate API documentation from OpenRPC specifications.
This monorepo provides tools for turning OpenRPC JSON specifications into markdown documentation. Use it standalone with the CLI, or integrate directly with Docusaurus for an interactive documentation site.
┌─────────────────┐ ┌──────────────────────┐ ┌─────────────────────┐
│ OpenRPC JSON │ ──► │ markdown-generator │ ──► │ Markdown / MDX │
│ Specification │ │ │ │ Documentation │
└─────────────────┘ └──────────────────────┘ └─────────────────────┘
│
▼
┌──────────────────────┐
│ docusaurus-plugin │
│ (interactive docs) │
└──────────────────────┘
Key Features:
- JSON Schema rendering
- Method parameters, results, and errors documentation
- Request/response examples with syntax highlighting
- Customizable output via mdast edit hooks
- Docusaurus plugin with two-column layout and interactive components
| Package | Description | Docs |
|---|---|---|
@open-rpc/markdown-generator |
Core library and CLI for markdown generation | README |
@open-rpc/docusaurus-plugin |
Docusaurus plugin with interactive components | README |
example-site |
Demo Docusaurus site for testing | README |
Generate markdown files directly from any OpenRPC specification:
# Install globally
npm install -g @open-rpc/markdown-generator
# Generate MDX files
openrpc-md ./openrpc.json -m ./docs/api
# Generate plain Markdown
openrpc-md ./openrpc.json -m ./docs/api -t mdSee the markdown-generator README for CLI options and programmatic API.
For Docusaurus sites, use the plugin for automatic generation with interactive components:
1. Install the plugin:
npm install @open-rpc/docusaurus-plugin2. Add to docusaurus.config.ts:
plugins: [
[
"@open-rpc/docusaurus-plugin",
{
openRPCSpecPath: "./openrpc.json",
docOutputPath: "./docs/api-reference",
},
],
],3. Configure sidebar in sidebars.ts:
const sidebars = {
apiSidebar: [
{
type: "category",
label: "API Reference",
items: [{ type: "autogenerated", dirName: "api-reference" }],
},
],
};See the docusaurus-plugin README for configuration options and component exports.
This project uses Bun as its JavaScript runtime and package manager.
# Install Bun
curl -fsSL https://bun.sh/install | bash# Install dependencies (also builds packages via postinstall)
bun install# Run tests
bun test
# Build all packages
bun run build:all
# Type check all packages
bun run types:all
# Lint
bun run lint
bun run lint:fixFor development with live reloading:
# From repo root - watches and rebuilds on changes
bun watch.tsThis watches the markdown-generator and docusaurus-plugin packages, rebuilding them when source files change. The example site will hot-reload with the updates.
The example-site package provides a Docusaurus site for testing:
cd packages/example-site
bun start- Fork the repository
- Create a feature branch
- Make your changes
- Run
bun testandbun run lint - Submit a pull request
This repo uses Changesets for versioning. Add a changeset for your changes:
bun changeset