Files
n8n_Demo/n8n-n8n-1.109.2/packages/@n8n/json-schema-to-zod/src/json-schema-to-zod.ts
2025-09-08 04:48:28 +08:00

16 lines
383 B
TypeScript
Executable File

import type { z } from 'zod';
import { parseSchema } from './parsers/parse-schema';
import type { JsonSchemaToZodOptions, JsonSchema } from './types';
export const jsonSchemaToZod = <T extends z.ZodTypeAny = z.ZodTypeAny>(
schema: JsonSchema,
options: JsonSchemaToZodOptions = {},
): T => {
return parseSchema(schema, {
path: [],
seen: new Map(),
...options,
}) as T;
};