UNPKG

json2zod

Version:

A CLI tool and library to convert JSON to Zod schemas with optional OpenAPI examples.

15 lines (14 loc) 753 B
/** * Generates the complete Zod schema string from the initial input JSON data. * This handles both single objects and arrays of objects at the top level. * * @param inputJson The parsed JSON object or array of objects to base the schema on. * @param options Configuration options. * @param options.addOpenApiExamples A boolean indicating whether to add example calls. Defaults to `false`. * @param options.exampleFormat The format to use for examples: 'openapi' (v3) or 'meta' (v4). Defaults to 'meta'. * @returns A string containing the complete TypeScript code for the Zod schema. */ export declare function generateZodSchema(inputJson: any, options?: { addOpenApiExamples?: boolean; exampleFormat?: 'openapi' | 'meta'; }): string;