UNPKG

json-schema-to-zod

Version:

Converts JSON schema objects or files into Zod schemas

7 lines (6 loc) 257 B
import { parseSchema } from "./parseSchema.js"; export const parseMultipleType = (schema, refs) => { return `z.union([${schema.type .map((type) => parseSchema({ ...schema, type }, { ...refs, withoutDefaults: true })) .join(", ")}])`; };