ArkType Integration
ArkType implements Standard Schema, so you can use it directly in your procedures without any extra setup. On top of that, @orpc/arktype provides a dedicated JSON Schema converter.
Installation
sh
npm install @orpc/arktype@beta arktypesh
yarn add @orpc/arktype@beta arktypesh
pnpm add @orpc/arktype@beta arktypesh
bun add @orpc/arktype@beta arktypesh
deno add npm:@orpc/arktype@beta npm: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.
ts
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.
ts
import { scope } from 'arktype'
const types = scope({
Planet: {
name: 'string',
neighbors: 'Planet[]',
},
})
const PlanetSchema = types.export().Planet
