@trpc/openapi
v11.15.0-alpha
Published
OpenAPI document generator for tRPC routers
Readme
OpenAPI schema generation for tRPC
The @trpc/openapi package generates an OpenAPI 3.1 specification from your tRPC router. Use the spec to:
- Generate a typed API client in any language
- Call tRPC endpoints via HTTP tools like Postman or Insomnia
- Enable AI agent integrations which can consume OpenAPI
Install
pnpm add @trpc/openapiQuick start
CLI
pnpm exec trpc-openapi ./src/server/router.tsProgrammatic
import { generateOpenAPIDocument } from '@trpc/openapi';
const doc = generateOpenAPIDocument('./src/server/router.ts', {
exportName: 'AppRouter',
title: 'My API',
version: '1.0.0',
});The generator statically analyses your router's TypeScript types — it never executes your code.
Documentation
Full documentation is available at trpc.io/docs/openapi.
AI Agents
If you use an AI coding agent, install tRPC skills for better code generation:
npx @tanstack/intent@latest installTODO
- [ ] SSE subscriptions
- [ ] non-json content types (might already work, needs tests)
- [ ] Improved handling of recursive/self-referencing types like trees/graphs - may be limited to 20 depth currently
- [ ] non-nodejs example
- [ ] an ai/mcp example
- [ ] Document breaking change detection via oasdiff
Maybes
- [ ] workaround for needing transformers even cross-ecosystem (some options documented)
- [ ] REST translation layer without TrpcEnvelope and with alternative search params formats for get
