import { core } from "zod/v4"; type JsonSchemaRegistry = core.$ZodRegistry; /** * The `override` parameter of `z.toJSONSchema` (its parameters type is not exported by every Zod 4 * version). */ export type JsonSchemaOverride = (ctx: { zodSchema: core.$ZodTypes; jsonSchema: core.JSONSchema.BaseSchema; path: (string | number)[]; }) => void; export interface IZod2JsonSchemaDefinitionsOpt { /** * Registry of the rest of the metadata (descriptions, titles, examples, ...). * Defaults to Zod's global registry, used by `.describe()` and `.meta()`. */ base?: JsonSchemaRegistry; /** * Custom `override` of `z.toJSONSchema`, called after the one of zod-to-x. */ override?: JsonSchemaOverride; } export interface IZod2JsonSchemaDefinitions { metadata: JsonSchemaRegistry; override: JsonSchemaOverride; } /** * Minimum Zod version whose JSON Schemas with definitions are valid with the `override`. */ export declare const MIN_ZOD_VERSION_FOR_JSON_SCHEMA_DEFINITIONS = "4.3.6"; /** * Creates the parameters of Zod's native `z.toJSONSchema` so that the schemas with a zod2x type * name (set with `zod2x` or by layered modeling) become definitions referenced with `$ref`. * * @example * const jsonSchema = z.toJSONSchema(UserModel, { * ...Zod2XConverters.zod2JsonSchemaDefinitions(), * }); * // { $ref: "#/$defs/UserModel", $defs: { UserModel: {...}, UserAddress: {...}, ... } } * * @remarks Requires Zod 4.3.6 or later. Earlier versions do not let the `override` reach every * schema and emit the `id` of the definitions, which makes the JSON Schemas invalid (e.g. it sets * the base URI of the references in draft-04). * * @param opt - Base metadata registry and custom override. * @returns The `metadata` and `override` parameters of `z.toJSONSchema`. They do not modify the * schemas or the base registry, and can be used for any number of conversions. * @throws If the installed Zod version is earlier than 4.3.6. */ export declare function zod2JsonSchemaDefinitions(opt?: IZod2JsonSchemaDefinitionsOpt): IZod2JsonSchemaDefinitions; export {};