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
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