/** * Type-safe wrapper for zod-to-json-schema conversion. * * This module isolates the necessary type coercion to a single location, * avoiding scattered eslint-disable comments and improving maintainability. * * The zod-to-json-schema library has slightly misaligned types between its * exported function signature and actual usage patterns. This wrapper * provides a clean interface while handling the type gymnastics internally. */ import { type JsonSchema7Type } from 'zod-to-json-schema'; import type { ZodTypeAny } from 'zod'; /** * Options for JSON Schema conversion. */ export interface JsonSchemaConversionOptions { /** * Strategy for handling $ref references. * - 'none': Inline all definitions (best for VS Code compatibility) * - 'root': Use $ref with definitions at root * - 'relative': Use relative $ref paths * @default 'none' */ $refStrategy?: 'none' | 'root' | 'relative'; /** * Target JSON Schema version. * @default 'jsonSchema7' */ target?: 'jsonSchema7' | 'jsonSchema2019-09' | 'openApi3'; /** * Whether to strip the additionalProperties field from object schemas. * Some consumers (e.g., VS Code package.json) don't support this field. * @default true */ stripAdditionalProperties?: boolean; } /** * Convert a Zod schema to JSON Schema. * * Uses jsonSchema7 target for VS Code compatibility by default. * Disables $ref generation for simpler, self-contained schemas. * * @param schema - Zod schema to convert * @param options - Conversion options * @returns JSON Schema (Draft 7 by default) * * @example * ```typescript * import { z } from 'zod'; * import { convertZodToJsonSchema } from './json-schema-converter'; * * const mySchema = z.object({ * name: z.string(), * age: z.number().optional(), * }); * * const jsonSchema = convertZodToJsonSchema(mySchema); * // { * // type: 'object', * // properties: { * // name: { type: 'string' }, * // age: { type: 'number' } * // }, * // required: ['name'] * // } * ``` */ export declare function convertZodToJsonSchema(schema: ZodTypeAny, options?: JsonSchemaConversionOptions): JsonSchema7Type; //# sourceMappingURL=json-schema-converter.d.ts.map