OpenAPIHandler— handles inbound HTTP requests and routes them to your procedures using OpenAPI-style path + method matching.OpenAPIReferencePlugin— serves an auto-generated spec at/spec.jsonand an interactive UI (Scalar or Swagger UI) at/.
OpenAPIHandler
TheOpenAPIHandler works like the RPCHandler but speaks standard HTTP instead of the oRPC binary protocol. Any client that sends a proper POST /planet/list request (with a JSON body) will work.
- Fetch (Cloudflare, Deno, Bun)
- Node.js
How routing works
By default, oRPC maps procedure paths to HTTP routes using a convention:planet.list→POST /planet/listplanet.find→POST /planet/find
route option on a procedure:
The
OpenAPIHandler only handles procedures that have a defined route (method + path), either explicitly via .route() or by convention. Procedures with no route config fall back to the default POST /{path} pattern.OpenAPIReferencePlugin
TheOpenAPIReferencePlugin is a plugin for RPCHandler or OpenAPIHandler that automatically:
- Generates your OpenAPI spec on demand
- Serves it at a configurable path (default:
/spec.json) - Renders an interactive UI (default: Scalar, also supports Swagger UI) at a configurable path (default:
/)
Plugin options
Schema converters for spec generation. Required to produce a meaningful spec.
specGenerateOptions
OpenAPIGeneratorGenerateOptions | ((options) => Promisable<OpenAPIGeneratorGenerateOptions>)
Options forwarded to
OpenAPIGenerator.generate(). Can be a value or an async function.URL path at which to serve the OpenAPI JSON document.
URL path at which to serve the interactive API UI.
The UI library to render.
'scalar' renders Scalar, 'swagger' renders Swagger UI.The document title for the docs page.
Arbitrary config object passed to the UI library (e.g. Scalar or Swagger UI config).
Raw HTML to inject into the
<head> of the docs page.URL of the external script bundle. Defaults to the CDN URL for Scalar or Swagger UI.
Fully custom HTML renderer. Override if you need complete control over the docs page.
Serving a UI separately
If you generate the spec yourself and want to serve Scalar or Swagger UI separately, you can host the spec JSON at any URL and point the UI at it:Calling the API from a non-oRPC client
Once served throughOpenAPIHandler, any HTTP client can call your API:
