Skip to content

v2.0.0-beta.51

Pre-release
Pre-release

Choose a tag to compare

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-inference documents procedures without .output and 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 createToolFactory no 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 of undefined, so .optional() and .default() no longer see a missing value. The spec marks these parameters required only when the schema rejects the empty collection. Docs
  • OpenAPI spec changes: a body whose files may be absent also lists application/json, and a GET input that is a record of primitive values becomes one free-form query parameter. 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:
    • Infer unknown instead of ThrowableError when next has no typed error  -  by @dinwwwh in #2464 (1df6f)

   🏎 Performance

  • client, tanstack-query, swr, pinia-colada, effect, openapi:
  • contract, server:
  • contract, server, openapi, msw:
  • effect:
  • server:
  • server, shared:
  • shared:
  • shared, server, next:
    • Make procedure handlers cheaper to type-check (−12% to −25% instantiations)  -  by @dinwwwh in #2457 (16fc7)
  • tanstack-query:
    View changes on GitHub