arktypea
arktype5mo ago
Isaac

Usage with JSON Schema

Hi all,

I'm in the process of migrating my project from Zod to ArkType, but I'm running into issues while converting my AI SDK tool input schemas.

The AI SDK requires non-Zod schemas to first be converted to JSON schema and be parsed with their jsonSchema helper, but when I do jsonSchema(arktypeSchema.toJsonSchema()) , I get the error:

Argument of type 'NonBooleanBranch' is not assignable to parameter of type 'JSONSchema7'.
  Type 'Constrainable' is not assignable to type 'JSONSchema7'.
    Types of property '$defs' are incompatible.
      Type 'Record<string, NonBooleanBranch> | undefined' is not assignable to type '{ [key: string]: JSONSchema7Definition; } | undefined'.
        Type 'Record<string, NonBooleanBranch>' is not assignable to type '{ [key: string]: JSONSchema7Definition; }'.
          'string' index signatures are incompatible.
            Type 'NonBooleanBranch' is not assignable to type 'JSONSchema7Definition'.
              Type 'Constrainable' is not assignable to type 'JSONSchema7Definition'.ts(2345)


This happens even when arktypeSchema is type({}). Any insights?
Was this page helpful?