The screenshot API for developers -
Try ScreenshotOne
Skip to content

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 arktype
sh
yarn add @orpc/arktype@beta arktype
sh
pnpm add @orpc/arktype@beta arktype
sh
bun add @orpc/arktype@beta arktype
sh
deno add npm:@orpc/arktype@beta npm:arktype

JSON 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

Released under the MIT License.