Repository navigation
v2.0.0-beta.51
Pre-release
Pre-release
Tip
v2 is close to stable. Tell us what hurt when migrating and what should change before stable: https://github.com/middleapi/orpc/discussions/2446
Highlights
This beta adds experimental OpenAPI schema inference from TypeScript types, and makes the server, contract, and client types cheaper to type-check. Two breaking changes affect AI SDK tool outputs and delimited query parameters.
import { OpenAPIGenerator } from '@orpc/experimental-openapi-inference'
// Drop-in for the generator in `@orpc/openapi`: converters still run first,
// and the rest is inferred from your TypeScript types
const generator = new OpenAPIGenerator({
converters: [new ZodToJsonSchemaConverter()],
})
const spec = await generator.generate(router, {
source: { file: './src/router.ts', export: 'router' },
})- OpenAPI type inference (experimental):
@orpc/experimental-openapi-inferencedocuments procedures without.outputand inputs written as plain types, using the TypeScript 7 compiler. Schemas match what the serializer sends, project types become named components, and JSDoc sets summaries, descriptions, and keywords like@format. Docs - Faster type-checking: builder chains,
.use(middleware), routers,RouterClient, and recursive client and router types are cheaper to check. Procedure handlers alone take 12% to 25% fewer instantiations. - Breaking — AI SDK tool outputs: tools from
createToolFactoryno longer validate or transform procedure outputs. They return what the handler returns, like plain AI SDK tools and the types already said. Docs - Breaking — delimited query styles: with
*-delimited-*styles, a missing or empty parameter now decodes as[]or{}instead ofundefined, so.optional()and.default()no longer see a missing value. The spec marks these parametersrequiredonly when the schema rejects the empty collection. Docs - OpenAPI spec changes: a body whose files may be absent also lists
application/json, and aGETinput that is a record of primitive values becomes one free-formqueryparameter. Docs
🚨 Breaking Changes
- ai-sdk: Disable output validation in
createToolFactory- by @dinwwwh in #2465 (67864) - openapi: Decode missing collection-style query parameters as empty collections - by @dinwwwh in #2462 (850fe)
🚀 Features
- openapi, openapi-inference: Infer OpenAPI schemas from TypeScript types - by @dinwwwh in #2479 (62b9b)
🐞 Bug Fixes
- Make options optional when context is an index-signature type - by @dinwwwh in #2472 (df5f5)
- client, tanstack-query, swr, pinia-colada, effect, openapi:
- contract:
- contract, server:
- server:
- shared:
🏎 Performance
- client, tanstack-query, swr, pinia-colada, effect, openapi:
- contract, server:
- contract, server, openapi, msw:
- effect:
- server:
- server, shared:
- shared:
- shared, server, next:
- tanstack-query: