toJsonSchema question

I am working on something that needs to convert standard schema validators to json schema. For seemingly similar validators, I am getting different behaviors between zod4's new json schema generatation and the arktype json schema generation that is leading to errors

import { type } from "arktype";
import * as z4 from "zod/v4";

const testArktype = type({
  category: "string",
  priority: "'low' | 'medium' | 'high'",
  name: "string",
});

const testZod = z4.object({
  category: z4.string(),
  priority: z4.enum(["low", "medium", "high"]),
  name: z4.string(),
});

console.dir(z4.toJSONSchema(testZod), {
  depth: null,
});
// {
//   $schema: "https://json-schema.org/draft/2020-12/schema",
//   type: "object",
//   properties: {
//     category: {
//       type: "string",
//     },
//     priority: {
//       type: "string",
//       enum: [ "low", "medium", "high" ],
//     },
//     name: {
//       type: "string",
//     },
//   },
//   required: [ "category", "priority", "name" ],
//   additionalProperties: false,
// }


console.dir(testArktype.toJsonSchema(), {
  depth: null,
});
// {
//   $schema: "https://json-schema.org/draft/2020-12/schema",
//   type: "object",
//   properties: {
//     category: {
//       type: "string",
//     },
//     name: {
//       type: "string",
//     },
//     priority: {
//       enum: [ "high", "low", "medium" ],
//     },
//   },
//   required: [ "category", "name", "priority" ],
// }


The arktype json schema output is missing the type annotation for priority, which is causing the library I am using to consume these json schemas to have issues. Is there any way to make the arktype json schema outputs fully verbose?
Was this page helpful?