ArkType Integration
Use ArkType types directly in oRPC via Standard Schema, with a dedicated JSON Schema converter for OpenAPI generation and Smart Coercion.
Installation
npm install @orpc/arktype@beta arktypepnpm add @orpc/arktype@beta arktypeyarn add @orpc/arktype@beta arktypebun add @orpc/arktype@beta arktypeJSON Schema Converter
ArkTypeToJsonSchemaConverter wraps ArkType’s built-in toJsonSchema and adds support for additional types such as bigint and Date. Use it with tools such as the OpenAPI Generator and Smart Coercion. It accepts the same options as ArkType’s toJsonSchema, see the source code and ArkType’s JSON Schema configuration docs for implementation details.
import { OpenAPIGenerator } from '@orpc/openapi'
import { ArkTypeToJsonSchemaConverter } from '@orpc/arktype'
const generator = new OpenAPIGenerator({
converters: [new ArkTypeToJsonSchemaConverter()],
})
Reusable Types
A common pattern is defining reusable or recursive types using scopes. The converter preserves them in $defs, which OpenAPIGenerator can then hoist into components.schemas.
import { scope } from 'arktype'
const types = scope({
Planet: {
name: 'string',
neighbors: 'Planet[]',
},
})
const PlanetSchema = types.export().Planet