@orval/zod 8.13.0 → 8.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +29 -2
- package/dist/index.mjs +125 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -38,8 +38,35 @@ declare const generateZodValidationSchemaDefinition: (schema: OpenApiSchemaObjec
|
|
|
38
38
|
* placeholder instead of being inlined.
|
|
39
39
|
*/
|
|
40
40
|
useReusableSchemas?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* When true (and `isZodV4`), the top-level (named component) schema emits a
|
|
43
|
+
* `.meta({ id, description?, deprecated? })` instead of `.describe(...)`.
|
|
44
|
+
* Set ONLY for top-level component-schema generation — recursive calls omit
|
|
45
|
+
* it, so nested schemas keep `.describe()` and never get a duplicate `id`.
|
|
46
|
+
*/
|
|
47
|
+
emitMeta?: boolean;
|
|
41
48
|
}) => ZodValidationSchemaDefinition;
|
|
42
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Runtime shape passed to the user-supplied `override.zod.params` function for
|
|
51
|
+
* every emitted validator. Exported so consumers can type their function with
|
|
52
|
+
* `import type { ZodParamsContext } from 'orval'` instead of hand-writing it.
|
|
53
|
+
*/
|
|
54
|
+
interface ZodParamsContext {
|
|
55
|
+
/** The OpenAPI `operationId`, or `''` for shared component schemas. */
|
|
56
|
+
operationId: string;
|
|
57
|
+
/** `'schema'` is used for shared component schemas with no owning operation. */
|
|
58
|
+
location: 'param' | 'query' | 'header' | 'body' | 'response' | 'schema';
|
|
59
|
+
/** Generated schema name, e.g. `CreateUserBody`, or the component name. */
|
|
60
|
+
schemaName: string;
|
|
61
|
+
/** Path to the current property within the schema. Only object property names are appended. */
|
|
62
|
+
fieldPath: string[];
|
|
63
|
+
/** The Zod method being emitted, e.g. `'string'`, `'min'`, `'email'`. */
|
|
64
|
+
validator: string;
|
|
65
|
+
}
|
|
66
|
+
interface ZodParamsInjection extends Pick<ZodParamsContext, 'operationId' | 'location' | 'schemaName'> {
|
|
67
|
+
mutator: GeneratorMutator;
|
|
68
|
+
}
|
|
69
|
+
declare const parseZodValidationSchemaDefinition: (input: ZodValidationSchemaDefinition, context: ContextSpec, coerceTypes: boolean | ZodCoerceType[] | undefined, strict: boolean, isZodV4: boolean, preprocess?: GeneratorMutator, paramsInjection?: ZodParamsInjection) => {
|
|
43
70
|
zod: string;
|
|
44
71
|
consts: string;
|
|
45
72
|
usedRefs: Set<string>;
|
|
@@ -96,5 +123,5 @@ declare const parseParameters: ({
|
|
|
96
123
|
declare const generateZod: ClientBuilder;
|
|
97
124
|
declare const builder: () => () => ClientGeneratorsBuilder;
|
|
98
125
|
//#endregion
|
|
99
|
-
export { ZodValidationSchemaDefinition, builder, builder as default, dereference, generateFormDataZodSchema, generateZod, generateZodValidationSchemaDefinition, getZodDependencies, isZodVersionV4, parseParameters, parseZodValidationSchemaDefinition, predefinedZodFormats };
|
|
126
|
+
export { ZodParamsContext, ZodParamsInjection, ZodValidationSchemaDefinition, builder, builder as default, dereference, generateFormDataZodSchema, generateZod, generateZodValidationSchemaDefinition, getZodDependencies, isZodVersionV4, parseParameters, parseZodValidationSchemaDefinition, predefinedZodFormats };
|
|
100
127
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { camel, compareVersions,
|
|
1
|
+
import { camel, compareVersions, escape, generateMutator, getFormDataFieldFileType, getNumberWord, getRefInfo, isBoolean, isNumber, isObject, isString, jsStringEscape, logVerbose, pascal, resolveRef, stringify } from "@orval/core";
|
|
2
2
|
import { unique } from "remeda";
|
|
3
3
|
//#region src/compatible-v4.ts
|
|
4
4
|
const getZodPackageVersion = (packageJson) => {
|
|
@@ -134,7 +134,7 @@ const generateZodValidationSchemaDefinition = (schema, context, name, strict, is
|
|
|
134
134
|
const isChainable = (k) => CHAINABLE_SIBLINGS.has(k);
|
|
135
135
|
if (siblings.every((k) => isChainable(k))) {
|
|
136
136
|
const functions = [["namedRef", {
|
|
137
|
-
name:
|
|
137
|
+
name: getRefInfo(schema.$ref, context).name,
|
|
138
138
|
sourceRef: schema.$ref
|
|
139
139
|
}]];
|
|
140
140
|
const consts = [];
|
|
@@ -171,6 +171,16 @@ const generateZodValidationSchemaDefinition = (schema, context, name, strict, is
|
|
|
171
171
|
const constsCounterValue = constsCounter ? pascal(getNumberWord(constsCounter)) : "";
|
|
172
172
|
constNameRegistry[name] = constsCounter;
|
|
173
173
|
const functions = [];
|
|
174
|
+
const pushDescriptionOrMeta = () => {
|
|
175
|
+
const description = typeof schema.description === "string" && schema.description.length > 0 ? schema.description : void 0;
|
|
176
|
+
const deprecated = "deprecated" in schema && schema.deprecated === true ? true : void 0;
|
|
177
|
+
if (rules?.emitMeta && isZodV4) {
|
|
178
|
+
const meta = { id: name };
|
|
179
|
+
if (description !== void 0) meta.description = description;
|
|
180
|
+
if (deprecated) meta.deprecated = true;
|
|
181
|
+
functions.push(["meta", meta]);
|
|
182
|
+
} else if (description !== void 0) functions.push(["describe", `'${jsStringEscape(description)}'`]);
|
|
183
|
+
};
|
|
174
184
|
const type = resolveZodType(schema);
|
|
175
185
|
const required = rules?.required ?? false;
|
|
176
186
|
const hasDefault = schema.default !== void 0;
|
|
@@ -251,6 +261,7 @@ const generateZodValidationSchemaDefinition = (schema, context, name, strict, is
|
|
|
251
261
|
if (!required && nullable) functions.push(["nullish", void 0]);
|
|
252
262
|
else if (nullable) functions.push(["nullable", void 0]);
|
|
253
263
|
else if (!required) functions.push(["optional", void 0]);
|
|
264
|
+
pushDescriptionOrMeta();
|
|
254
265
|
return {
|
|
255
266
|
functions,
|
|
256
267
|
consts
|
|
@@ -443,13 +454,32 @@ const generateZodValidationSchemaDefinition = (schema, context, name, strict, is
|
|
|
443
454
|
else if (nullable) functions.push(["nullable", void 0]);
|
|
444
455
|
else if (!required && !hasDefault) functions.push(["optional", void 0]);
|
|
445
456
|
if (hasDefault) functions.push(["default", defaultVarName]);
|
|
446
|
-
|
|
457
|
+
pushDescriptionOrMeta();
|
|
447
458
|
return {
|
|
448
459
|
functions,
|
|
449
460
|
consts: unique(consts)
|
|
450
461
|
};
|
|
451
462
|
};
|
|
452
|
-
const
|
|
463
|
+
const PARAMS_MODIFIER_VALIDATORS = new Set([
|
|
464
|
+
"optional",
|
|
465
|
+
"nullable",
|
|
466
|
+
"nullish",
|
|
467
|
+
"default",
|
|
468
|
+
"describe",
|
|
469
|
+
"unknown",
|
|
470
|
+
"any",
|
|
471
|
+
"never",
|
|
472
|
+
"null",
|
|
473
|
+
"undefined",
|
|
474
|
+
"void"
|
|
475
|
+
]);
|
|
476
|
+
const PARAMS_MERGE_INTO_OPTIONS_VALIDATORS = new Set([
|
|
477
|
+
"datetime",
|
|
478
|
+
"time",
|
|
479
|
+
"iso.datetime",
|
|
480
|
+
"iso.time"
|
|
481
|
+
]);
|
|
482
|
+
const parseZodValidationSchemaDefinition = (input, context, coerceTypes = false, strict, isZodV4, preprocess, paramsInjection) => {
|
|
453
483
|
if (input.functions.length === 0) return {
|
|
454
484
|
zod: "",
|
|
455
485
|
consts: "",
|
|
@@ -471,13 +501,32 @@ const parseZodValidationSchemaDefinition = (input, context, coerceTypes = false,
|
|
|
471
501
|
if (isNumber(value) || isBoolean(value)) return `${value}`;
|
|
472
502
|
return "";
|
|
473
503
|
};
|
|
474
|
-
const
|
|
504
|
+
const buildParamsArg = (fn, fieldPath) => {
|
|
505
|
+
if (!paramsInjection) return void 0;
|
|
506
|
+
if (PARAMS_MODIFIER_VALIDATORS.has(fn)) return void 0;
|
|
507
|
+
const ctx = {
|
|
508
|
+
operationId: paramsInjection.operationId,
|
|
509
|
+
location: paramsInjection.location,
|
|
510
|
+
schemaName: paramsInjection.schemaName,
|
|
511
|
+
fieldPath: [...fieldPath],
|
|
512
|
+
validator: fn
|
|
513
|
+
};
|
|
514
|
+
return `${paramsInjection.mutator.name}(${JSON.stringify(ctx)})`;
|
|
515
|
+
};
|
|
516
|
+
const parseProperty = (property, fieldPath = []) => {
|
|
475
517
|
const [fn, args = ""] = property;
|
|
476
518
|
if (fn === "namedRef") {
|
|
477
519
|
const refArgs = args;
|
|
478
520
|
usedRefs.add(refArgs.name);
|
|
479
521
|
return `__REF_${refArgs.name}__`;
|
|
480
522
|
}
|
|
523
|
+
if (fn === "meta") {
|
|
524
|
+
const metaArgs = args;
|
|
525
|
+
const parts = [`id: '${jsStringEscape(metaArgs.id)}'`];
|
|
526
|
+
if (metaArgs.description !== void 0) parts.push(`description: '${jsStringEscape(metaArgs.description)}'`);
|
|
527
|
+
if (metaArgs.deprecated) parts.push("deprecated: true");
|
|
528
|
+
return `.meta({ ${parts.join(", ")} })`;
|
|
529
|
+
}
|
|
481
530
|
if (fn === "fileOrString") return "zod.instanceof(File).or(zod.string())";
|
|
482
531
|
if (fn === "allOf") {
|
|
483
532
|
const allOfArgs = args;
|
|
@@ -499,7 +548,7 @@ const parseZodValidationSchemaDefinition = (input, context, coerceTypes = false,
|
|
|
499
548
|
if (allConsts.length > 0) appendConstsChunk(allConsts);
|
|
500
549
|
const mergedObjectString = `zod.${getObjectFunctionName(isZodV4, strict)}({
|
|
501
550
|
${Object.entries(mergedProperties).map(([key, schema]) => {
|
|
502
|
-
const value = schema.functions.map((prop) => parseProperty(prop)).join("");
|
|
551
|
+
const value = schema.functions.map((prop) => parseProperty(prop, [...fieldPath, key])).join("");
|
|
503
552
|
appendConstsChunk(schema.consts.join("\n"));
|
|
504
553
|
return ` "${key}": ${value.startsWith(".") ? "zod" : ""}${value}`;
|
|
505
554
|
}).join(",\n")}
|
|
@@ -509,7 +558,7 @@ ${Object.entries(mergedProperties).map(([key, schema]) => {
|
|
|
509
558
|
}
|
|
510
559
|
let acc = "";
|
|
511
560
|
for (const partSchema of allOfArgs) {
|
|
512
|
-
const value = partSchema.functions.map((prop) => parseProperty(prop)).join("");
|
|
561
|
+
const value = partSchema.functions.map((prop) => parseProperty(prop, fieldPath)).join("");
|
|
513
562
|
const valueWithZod = `${value.startsWith(".") ? "zod" : ""}${value}`;
|
|
514
563
|
if (partSchema.consts.length > 0) appendConstsChunk(partSchema.consts.join("\n"));
|
|
515
564
|
if (acc.length === 0) acc = valueWithZod;
|
|
@@ -519,9 +568,12 @@ ${Object.entries(mergedProperties).map(([key, schema]) => {
|
|
|
519
568
|
}
|
|
520
569
|
if (fn === "oneOf" || fn === "anyOf") {
|
|
521
570
|
const unionArgs = args;
|
|
522
|
-
if (unionArgs.length === 1)
|
|
571
|
+
if (unionArgs.length === 1) {
|
|
572
|
+
appendConstsChunk(unionArgs[0].consts.join("\n"));
|
|
573
|
+
return unionArgs[0].functions.map((prop) => parseProperty(prop, fieldPath)).join("");
|
|
574
|
+
}
|
|
523
575
|
return `.union([${unionArgs.map(({ functions, consts: argConsts }) => {
|
|
524
|
-
const value = functions.map((prop) => parseProperty(prop)).join("");
|
|
576
|
+
const value = functions.map((prop) => parseProperty(prop, fieldPath)).join("");
|
|
525
577
|
const valueWithZod = `${value.startsWith(".") ? "zod" : ""}${value}`;
|
|
526
578
|
appendConstsChunk(argConsts.join("\n"));
|
|
527
579
|
return valueWithZod;
|
|
@@ -529,7 +581,7 @@ ${Object.entries(mergedProperties).map(([key, schema]) => {
|
|
|
529
581
|
}
|
|
530
582
|
if (fn === "additionalProperties") {
|
|
531
583
|
const additionalPropertiesArgs = args;
|
|
532
|
-
const value = additionalPropertiesArgs.functions.map((prop) => parseProperty(prop)).join("");
|
|
584
|
+
const value = additionalPropertiesArgs.functions.map((prop) => parseProperty(prop, fieldPath)).join("");
|
|
533
585
|
const valueWithZod = `${value.startsWith(".") ? "zod" : ""}${value}`;
|
|
534
586
|
if (Array.isArray(additionalPropertiesArgs.consts)) appendConstsChunk(additionalPropertiesArgs.consts.join("\n"));
|
|
535
587
|
return `zod.record(zod.string(), ${valueWithZod})`;
|
|
@@ -538,7 +590,7 @@ ${Object.entries(mergedProperties).map(([key, schema]) => {
|
|
|
538
590
|
const objectArgs = args;
|
|
539
591
|
const parsedObject = `zod.${fn === "looseObject" ? isZodV4 ? "looseObject" : "object" : getObjectFunctionName(isZodV4, strict)}({
|
|
540
592
|
${Object.entries(objectArgs).map(([key, schema]) => {
|
|
541
|
-
const value = schema.functions.map((prop) => parseProperty(prop)).join("");
|
|
593
|
+
const value = schema.functions.map((prop) => parseProperty(prop, [...fieldPath, key])).join("");
|
|
542
594
|
appendConstsChunk(schema.consts.join("\n"));
|
|
543
595
|
return ` "${key}": ${value.startsWith(".") ? "zod" : ""}${value}`;
|
|
544
596
|
}).join(",\n")}
|
|
@@ -549,20 +601,26 @@ ${Object.entries(objectArgs).map(([key, schema]) => {
|
|
|
549
601
|
if (fn === "passthrough") return ".passthrough()";
|
|
550
602
|
if (fn === "array") {
|
|
551
603
|
const arrayArgs = args;
|
|
552
|
-
const value = arrayArgs.functions.map((prop) => parseProperty(prop)).join("");
|
|
604
|
+
const value = arrayArgs.functions.map((prop) => parseProperty(prop, fieldPath)).join("");
|
|
553
605
|
if (isString(arrayArgs.consts)) appendConstsChunk(arrayArgs.consts);
|
|
554
606
|
else if (Array.isArray(arrayArgs.consts)) appendConstsChunk(arrayArgs.consts.join("\n"));
|
|
555
607
|
return `.array(${value.startsWith(".") ? "zod" : ""}${value})`;
|
|
556
608
|
}
|
|
557
609
|
if (fn === "strict" && !isZodV4) return ".strict()";
|
|
558
610
|
if (fn === "tuple") return `zod.tuple([${args.map((x) => {
|
|
559
|
-
const value = x.functions.map((prop) => parseProperty(prop)).join("");
|
|
611
|
+
const value = x.functions.map((prop) => parseProperty(prop, fieldPath)).join("");
|
|
560
612
|
return `${value.startsWith(".") ? "zod" : ""}${value}`;
|
|
561
613
|
}).join(",\n")}])`;
|
|
562
|
-
if (fn === "rest") return `.rest(zod${args.functions.map((prop) => parseProperty(prop)).join("")})`;
|
|
614
|
+
if (fn === "rest") return `.rest(zod${args.functions.map((prop) => parseProperty(prop, fieldPath)).join("")})`;
|
|
563
615
|
const shouldCoerceType = coerceTypes && (Array.isArray(coerceTypes) ? coerceTypes.includes(fn) : COERCIBLE_TYPES.has(fn));
|
|
564
|
-
|
|
565
|
-
|
|
616
|
+
const formattedArgs = formatFunctionArgs(args);
|
|
617
|
+
const paramsArg = buildParamsArg(fn, fieldPath);
|
|
618
|
+
let combinedArgs;
|
|
619
|
+
if (paramsArg && formattedArgs && PARAMS_MERGE_INTO_OPTIONS_VALIDATORS.has(fn)) combinedArgs = `{ ...${formattedArgs}, ...${paramsArg} }`;
|
|
620
|
+
else if (paramsArg) combinedArgs = formattedArgs ? `${formattedArgs}, ${paramsArg}` : paramsArg;
|
|
621
|
+
else combinedArgs = formattedArgs;
|
|
622
|
+
if (fn !== "date" && shouldCoerceType || fn === "date" && shouldCoerceType && context.output.override.useDates) return `.coerce.${fn}(${combinedArgs})`;
|
|
623
|
+
return `.${fn}(${combinedArgs})`;
|
|
566
624
|
};
|
|
567
625
|
appendConstsChunk(input.consts.join("\n"));
|
|
568
626
|
const schema = input.functions.map((prop) => parseProperty(prop)).join("");
|
|
@@ -804,7 +862,7 @@ const parseParameters = ({ data, context, operationName, isZodV4, strict, genera
|
|
|
804
862
|
params
|
|
805
863
|
};
|
|
806
864
|
};
|
|
807
|
-
const generateZodRoute = async ({ operationName, verb, override }, { pathRoute, context, output }) => {
|
|
865
|
+
const generateZodRoute = async ({ operationId, operationName, verb, override }, { pathRoute, context, output }) => {
|
|
808
866
|
const isZodV4 = !!context.output.packageJson && isZodVersionV4(context.output.packageJson);
|
|
809
867
|
const useReusableSchemas = context.output.override.zod.generateReusableSchemas;
|
|
810
868
|
const spec = context.spec.paths?.[pathRoute];
|
|
@@ -847,7 +905,21 @@ const generateZodRoute = async ({ operationName, verb, override }, { pathRoute,
|
|
|
847
905
|
workspace: context.workspace,
|
|
848
906
|
tsconfig: context.output.tsconfig
|
|
849
907
|
}) : void 0;
|
|
850
|
-
|
|
908
|
+
const paramsMutator = override.zod.params ? await generateMutator({
|
|
909
|
+
output,
|
|
910
|
+
mutator: override.zod.params,
|
|
911
|
+
name: `${operationName}ZodParams`,
|
|
912
|
+
workspace: context.workspace,
|
|
913
|
+
tsconfig: context.output.tsconfig
|
|
914
|
+
}) : void 0;
|
|
915
|
+
const pascalOperationName = pascal(operationName);
|
|
916
|
+
const makeParamsInjection = (location, schemaSuffix) => paramsMutator ? {
|
|
917
|
+
mutator: paramsMutator,
|
|
918
|
+
operationId,
|
|
919
|
+
location,
|
|
920
|
+
schemaName: `${pascalOperationName}${schemaSuffix}`
|
|
921
|
+
} : void 0;
|
|
922
|
+
let inputParams = parseZodValidationSchemaDefinition(parsedParameters.params, context, override.zod.coerce.param, override.zod.strict.param, isZodV4, preprocessParams, makeParamsInjection("param", "Params"));
|
|
851
923
|
const preprocessQueryParams = override.zod.preprocess?.query ? await generateMutator({
|
|
852
924
|
output,
|
|
853
925
|
mutator: override.zod.preprocess.response,
|
|
@@ -855,7 +927,7 @@ const generateZodRoute = async ({ operationName, verb, override }, { pathRoute,
|
|
|
855
927
|
workspace: context.workspace,
|
|
856
928
|
tsconfig: context.output.tsconfig
|
|
857
929
|
}) : void 0;
|
|
858
|
-
let inputQueryParams = parseZodValidationSchemaDefinition(parsedParameters.queryParams, context, override.zod.coerce.query, override.zod.strict.query, isZodV4, preprocessQueryParams);
|
|
930
|
+
let inputQueryParams = parseZodValidationSchemaDefinition(parsedParameters.queryParams, context, override.zod.coerce.query, override.zod.strict.query, isZodV4, preprocessQueryParams, makeParamsInjection("query", "QueryParams"));
|
|
859
931
|
const preprocessHeader = override.zod.preprocess?.header ? await generateMutator({
|
|
860
932
|
output,
|
|
861
933
|
mutator: override.zod.preprocess.response,
|
|
@@ -863,7 +935,7 @@ const generateZodRoute = async ({ operationName, verb, override }, { pathRoute,
|
|
|
863
935
|
workspace: context.workspace,
|
|
864
936
|
tsconfig: context.output.tsconfig
|
|
865
937
|
}) : void 0;
|
|
866
|
-
let inputHeaders = parseZodValidationSchemaDefinition(parsedParameters.headers, context, override.zod.coerce.header, override.zod.strict.header, isZodV4, preprocessHeader);
|
|
938
|
+
let inputHeaders = parseZodValidationSchemaDefinition(parsedParameters.headers, context, override.zod.coerce.header, override.zod.strict.header, isZodV4, preprocessHeader, makeParamsInjection("header", "Header"));
|
|
867
939
|
const preprocessBody = override.zod.preprocess?.body ? await generateMutator({
|
|
868
940
|
output,
|
|
869
941
|
mutator: override.zod.preprocess.response,
|
|
@@ -871,7 +943,7 @@ const generateZodRoute = async ({ operationName, verb, override }, { pathRoute,
|
|
|
871
943
|
workspace: context.workspace,
|
|
872
944
|
tsconfig: context.output.tsconfig
|
|
873
945
|
}) : void 0;
|
|
874
|
-
let inputBody = parseZodValidationSchemaDefinition(parsedBody.input, context, override.zod.coerce.body, override.zod.strict.body, isZodV4, preprocessBody);
|
|
946
|
+
let inputBody = parseZodValidationSchemaDefinition(parsedBody.input, context, override.zod.coerce.body, override.zod.strict.body, isZodV4, preprocessBody, makeParamsInjection("body", "Body"));
|
|
875
947
|
const preprocessResponse = override.zod.preprocess?.response ? await generateMutator({
|
|
876
948
|
output,
|
|
877
949
|
mutator: override.zod.preprocess.response,
|
|
@@ -879,7 +951,7 @@ const generateZodRoute = async ({ operationName, verb, override }, { pathRoute,
|
|
|
879
951
|
workspace: context.workspace,
|
|
880
952
|
tsconfig: context.output.tsconfig
|
|
881
953
|
}) : void 0;
|
|
882
|
-
const inputResponses = parsedResponses.map((parsedResponse) => parseZodValidationSchemaDefinition(parsedResponse.input, context, override.zod.coerce.response, override.zod.strict.response, isZodV4, preprocessResponse));
|
|
954
|
+
const inputResponses = parsedResponses.map((parsedResponse, index) => parseZodValidationSchemaDefinition(parsedResponse.input, context, override.zod.coerce.response, override.zod.strict.response, isZodV4, preprocessResponse, makeParamsInjection("response", responses[index][0] ? `${responses[index][0]}Response` : "Response")));
|
|
883
955
|
const SENTINEL_PATTERN = /__REF_([A-Za-z_$][A-Za-z0-9_$]*)__/g;
|
|
884
956
|
const rewriteSentinels = (s) => s.replaceAll(SENTINEL_PATTERN, (_m, name) => name);
|
|
885
957
|
const allUsedRefs = new Set([
|
|
@@ -916,27 +988,50 @@ const generateZodRoute = async ({ operationName, verb, override }, { pathRoute,
|
|
|
916
988
|
mutators: [],
|
|
917
989
|
usedRefs: /* @__PURE__ */ new Set()
|
|
918
990
|
};
|
|
919
|
-
const pascalOperationName = pascal(operationName);
|
|
920
991
|
const useBrandedTypes = override.zod.useBrandedTypes;
|
|
921
992
|
const brand = (name) => useBrandedTypes ? isZodV4 ? `.brand("${name}")` : `.brand<"${name}">()` : "";
|
|
993
|
+
const localTaken = new Set(allUsedRefs);
|
|
994
|
+
const allocateExportName = (baseName, hasItem) => {
|
|
995
|
+
const collides = (name) => localTaken.has(name) || hasItem && localTaken.has(`${name}Item`);
|
|
996
|
+
const reserve = (name) => {
|
|
997
|
+
localTaken.add(name);
|
|
998
|
+
if (hasItem) localTaken.add(`${name}Item`);
|
|
999
|
+
};
|
|
1000
|
+
if (!collides(baseName)) {
|
|
1001
|
+
reserve(baseName);
|
|
1002
|
+
return baseName;
|
|
1003
|
+
}
|
|
1004
|
+
let counter = 0;
|
|
1005
|
+
let candidate = `${baseName}Schema`;
|
|
1006
|
+
while (collides(candidate)) {
|
|
1007
|
+
counter += 1;
|
|
1008
|
+
candidate = `${baseName}Schema${counter}`;
|
|
1009
|
+
}
|
|
1010
|
+
reserve(candidate);
|
|
1011
|
+
return candidate;
|
|
1012
|
+
};
|
|
1013
|
+
const paramsName = allocateExportName(`${pascalOperationName}Params`, false);
|
|
1014
|
+
const queryParamsName = allocateExportName(`${pascalOperationName}QueryParams`, false);
|
|
1015
|
+
const headerName = allocateExportName(`${pascalOperationName}Header`, false);
|
|
1016
|
+
const bodyName = allocateExportName(`${pascalOperationName}Body`, parsedBody.isArray);
|
|
922
1017
|
return {
|
|
923
1018
|
implementation: [
|
|
924
1019
|
...inputParams.consts ? [inputParams.consts] : [],
|
|
925
|
-
...inputParams.zod ? [`export const ${
|
|
1020
|
+
...inputParams.zod ? [`export const ${paramsName} = ${inputParams.zod}${brand(paramsName)}`] : [],
|
|
926
1021
|
...inputQueryParams.consts ? [inputQueryParams.consts] : [],
|
|
927
|
-
...inputQueryParams.zod ? [`export const ${
|
|
1022
|
+
...inputQueryParams.zod ? [`export const ${queryParamsName} = ${inputQueryParams.zod}${brand(queryParamsName)}`] : [],
|
|
928
1023
|
...inputHeaders.consts ? [inputHeaders.consts] : [],
|
|
929
|
-
...inputHeaders.zod ? [`export const ${
|
|
1024
|
+
...inputHeaders.zod ? [`export const ${headerName} = ${inputHeaders.zod}${brand(headerName)}`] : [],
|
|
930
1025
|
...inputBody.consts ? [inputBody.consts] : [],
|
|
931
|
-
...inputBody.zod ? [parsedBody.isArray ? `export const ${
|
|
932
|
-
export const ${
|
|
1026
|
+
...inputBody.zod ? [parsedBody.isArray ? `export const ${bodyName}Item = ${inputBody.zod}
|
|
1027
|
+
export const ${bodyName} = zod.array(${bodyName}Item)${parsedBody.rules?.min ? `.min(${parsedBody.rules.min})` : ""}${parsedBody.rules?.max ? `.max(${parsedBody.rules.max})` : ""}${brand(bodyName)}` : `export const ${bodyName} = ${inputBody.zod}${brand(bodyName)}`] : [],
|
|
933
1028
|
...inputResponses.flatMap((inputResponse, index) => {
|
|
934
|
-
const operationResponse = pascal(`${operationName}-${responses[index][0]}-response`);
|
|
1029
|
+
const operationResponse = allocateExportName(pascal(`${operationName}-${responses[index][0]}-response`), parsedResponses[index].isArray);
|
|
935
1030
|
return [...inputResponse.consts ? [inputResponse.consts] : [], ...inputResponse.zod ? [parsedResponses[index].isArray ? `export const ${operationResponse}Item = ${inputResponse.zod}
|
|
936
1031
|
export const ${operationResponse} = zod.array(${operationResponse}Item)${parsedResponses[index].rules?.min ? `.min(${parsedResponses[index].rules.min})` : ""}${parsedResponses[index].rules?.max ? `.max(${parsedResponses[index].rules.max})` : ""}${brand(operationResponse)}` : `export const ${operationResponse} = ${inputResponse.zod}${brand(operationResponse)}`] : []];
|
|
937
1032
|
})
|
|
938
1033
|
].join("\n\n"),
|
|
939
|
-
mutators: preprocessResponse ? [preprocessResponse] : [],
|
|
1034
|
+
mutators: [...preprocessResponse ? [preprocessResponse] : [], ...paramsMutator ? [paramsMutator] : []],
|
|
940
1035
|
usedRefs: useReusableSchemas ? allUsedRefs : /* @__PURE__ */ new Set()
|
|
941
1036
|
};
|
|
942
1037
|
};
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/compatible-v4.ts","../src/index.ts"],"sourcesContent":["import { compareVersions, type PackageJson } from '@orval/core';\n\nconst getZodPackageVersion = (packageJson: PackageJson) => {\n return (\n packageJson.resolvedVersions?.zod ??\n packageJson.dependencies?.zod ??\n packageJson.devDependencies?.zod ??\n packageJson.peerDependencies?.zod\n );\n};\n\nexport const isZodVersionV4 = (packageJson: PackageJson) => {\n const version = getZodPackageVersion(packageJson);\n\n if (!version) {\n return false;\n }\n\n const withoutRc = version.split('-')[0];\n\n return compareVersions(withoutRc, '4.0.0');\n};\n\nexport const getZodDateFormat = (isZodV4: boolean) => {\n return isZodV4 ? 'iso.date' : 'date';\n};\n\nexport const getZodTimeFormat = (isZodV4: boolean) => {\n return isZodV4 ? 'iso.time' : 'time';\n};\n\nexport const getZodDateTimeFormat = (isZodV4: boolean) => {\n return isZodV4 ? 'iso.datetime' : 'datetime';\n};\n\ntype ParameterDefinitions = Record<string, unknown>;\ntype ParameterFunction = [string, ParameterDefinitions | undefined];\nexport const getParameterFunctions = (\n isZodV4: boolean,\n strict: boolean,\n parameters: ParameterDefinitions,\n): ParameterFunction[] => {\n if (isZodV4 && strict) {\n return [['strictObject', parameters]];\n } else {\n return strict\n ? [\n ['object', parameters],\n ['strict', undefined],\n ]\n : [['object', parameters]];\n }\n};\n\nexport const getObjectFunctionName = (isZodV4: boolean, strict: boolean) => {\n return isZodV4 && strict ? 'strictObject' : 'object';\n};\n\n/**\n * Returns the object constructor to use for open/generic objects.\n *\n * - Zod v4 supports `zod.looseObject({...})` directly.\n * - Zod v3 falls back to `zod.object({...})` and is finalized with\n * `.passthrough()` during parsing.\n */\nexport const getLooseObjectFunctionName = (isZodV4: boolean) => {\n return isZodV4 ? 'looseObject' : 'object';\n};\n","/* eslint-disable unicorn/no-array-reduce */\n\nimport {\n camel,\n type ClientBuilder,\n type ClientGeneratorsBuilder,\n type ContextSpec,\n conventionName,\n escape,\n generateMutator,\n type GeneratorDependency,\n type GeneratorMutator,\n type GeneratorOptions,\n type GeneratorVerbOptions,\n getFormDataFieldFileType,\n getNumberWord,\n getRefInfo,\n isBoolean,\n isNumber,\n isObject,\n isString,\n jsStringEscape,\n logVerbose,\n type OpenApiParameterObject,\n type OpenApiReferenceObject,\n type OpenApiRequestBodyObject,\n type OpenApiResponseObject,\n type OpenApiSchemaObject,\n pascal,\n resolveRef,\n stringify,\n type ZodCoerceType,\n} from '@orval/core';\nimport { unique } from 'remeda';\n\nimport {\n getLooseObjectFunctionName,\n getObjectFunctionName,\n getParameterFunctions,\n getZodDateFormat,\n getZodDateTimeFormat,\n getZodTimeFormat,\n isZodVersionV4,\n} from './compatible-v4';\n\nconst ZOD_DEPENDENCIES: GeneratorDependency[] = [\n {\n exports: [\n {\n default: false,\n name: 'zod',\n syntheticDefaultImport: false,\n namespaceImport: true,\n values: true,\n },\n ],\n dependency: 'zod',\n },\n];\n\nexport const getZodDependencies = () => ZOD_DEPENDENCIES;\n\n/**\n * values that may appear in \"type\". Equals SchemaObjectType\n */\nconst possibleSchemaTypes = new Set([\n 'integer',\n 'number',\n 'string',\n 'boolean',\n 'object',\n 'strictObject',\n 'null',\n 'array',\n]);\n\nexport const predefinedZodFormats = new Set([\n 'date',\n 'time',\n 'date-time',\n 'email',\n 'uri',\n 'hostname',\n 'uuid',\n]);\n\ntype ResolvedZodType =\n | string\n | {\n multiType: string[];\n };\n\nconst resolveZodType = (schema: OpenApiSchemaObject): ResolvedZodType => {\n const schemaTypeValue = schema.type as unknown;\n\n // Handle array of types (OpenAPI 3.1+)\n if (Array.isArray(schemaTypeValue)) {\n // Filter out 'null' type as it's handled separately via nullable\n const nonNullTypes = schemaTypeValue\n .filter((t): t is string => isString(t))\n .filter((t) => t !== 'null' && possibleSchemaTypes.has(t))\n .map((t) => (t === 'integer' ? 'number' : t));\n\n // If multiple types, return a special marker for union handling\n if (nonNullTypes.length > 1) {\n return { multiType: nonNullTypes };\n }\n\n // Single type\n const type = nonNullTypes[0];\n\n // Handle prefixItems for tuples\n if (type === 'array' && 'prefixItems' in schema) {\n return 'tuple';\n }\n\n return type;\n }\n\n // Handle single type value\n const type = isString(schemaTypeValue) ? schemaTypeValue : undefined;\n\n // TODO: if \"prefixItems\" exists and type is \"array\", then generate a \"tuple\"\n if (schema.type === 'array' && 'prefixItems' in schema) {\n return 'tuple';\n }\n\n switch (type) {\n case 'integer': {\n return 'number';\n }\n default: {\n return type ?? 'unknown';\n }\n }\n};\n\n// https://github.com/colinhacks/zod#coercion-for-primitives\nconst COERCIBLE_TYPES = new Set([\n 'string',\n 'number',\n 'boolean',\n 'bigint',\n 'date',\n]);\n\nexport interface ZodValidationSchemaDefinition {\n functions: [string, unknown][];\n consts: string[];\n}\n\nconst minAndMaxTypes = new Set(['number', 'string', 'array']);\n\nconst removeReadOnlyProperties = (\n schema: OpenApiSchemaObject,\n): OpenApiSchemaObject => {\n if (schema.properties && isObject(schema.properties)) {\n const filteredProperties: Record<string, OpenApiSchemaObject> = {};\n\n for (const [key, value] of Object.entries(schema.properties)) {\n if (isObject(value) && 'readOnly' in value && value.readOnly) {\n continue;\n }\n filteredProperties[key] = value as OpenApiSchemaObject;\n }\n\n return {\n ...(schema as Record<string, unknown>),\n properties: filteredProperties,\n };\n }\n if (schema.items && isObject(schema.items) && 'properties' in schema.items) {\n return {\n ...(schema as Record<string, unknown>),\n items: removeReadOnlyProperties(schema.items as OpenApiSchemaObject),\n };\n }\n return schema;\n};\n\ninterface DateTimeOptions {\n offset?: boolean;\n local?: boolean;\n precision?: number;\n}\n\ninterface TimeOptions {\n precision?: -1 | 0 | 1 | 2 | 3;\n}\n\n/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */\n\nconst COMPONENT_SCHEMAS_REF_PATTERN = /^#\\/components\\/schemas\\/[^/]+$/;\n\nconst isComponentSchemaRef = (ref: string): boolean =>\n COMPONENT_SCHEMAS_REF_PATTERN.test(ref);\n\nexport const generateZodValidationSchemaDefinition = (\n schema: OpenApiSchemaObject | OpenApiReferenceObject | undefined,\n context: ContextSpec,\n name: string,\n strict: boolean,\n isZodV4: boolean,\n rules?: {\n required?: boolean;\n dateTimeOptions?: DateTimeOptions;\n timeOptions?: TimeOptions;\n /**\n * Override schemas for properties at THIS level only.\n * Not passed to nested schemas. Used by form-data for file type handling.\n */\n propertyOverrides?: Record<string, ZodValidationSchemaDefinition>;\n /**\n * Internal registry to keep generated const names unique within a single\n * schema generation tree without leaking suffixes across unrelated top-level\n * schemas.\n */\n constNameRegistry?: Record<string, number>;\n /**\n * When true, plain `$ref`s into `#/components/schemas/*` emit a `namedRef`\n * placeholder instead of being inlined.\n */\n useReusableSchemas?: boolean;\n },\n): ZodValidationSchemaDefinition => {\n if (!schema) return { functions: [], consts: [] };\n\n // Ref-aware path: emit a placeholder that the orchestrator will rewrite into\n // either a direct identifier or `z.lazy(() => Name)`.\n if (\n rules?.useReusableSchemas &&\n '$ref' in schema &&\n typeof schema.$ref === 'string' &&\n isComponentSchemaRef(schema.$ref)\n ) {\n const siblings = Object.keys(schema).filter((k) => k !== '$ref');\n\n const CHAINABLE_SIBLINGS = new Set(['nullable', 'default', 'description']);\n const isChainable = (k: string) => CHAINABLE_SIBLINGS.has(k);\n const allSiblingsChainable = siblings.every((k) => isChainable(k));\n\n if (allSiblingsChainable) {\n const refName = conventionName(\n getRefInfo(schema.$ref, context).originalName,\n context.output.namingConvention,\n );\n const functions: [string, unknown][] = [\n ['namedRef', { name: refName, sourceRef: schema.$ref }],\n ];\n const consts: string[] = [];\n\n const refSchema = schema as OpenApiSchemaObject & {\n $ref: string;\n nullable?: boolean;\n default?: unknown;\n description?: string;\n };\n const refRequired = rules.required ?? false;\n const refHasDefault = refSchema.default !== undefined;\n\n // Match the main-path modifier ordering: nullability/optional first,\n // then default, then describe. Combining `.default()` with `.optional()`\n // is wrong in zod — `.optional()` short-circuits on `undefined` before\n // the inner default runs — so skip `.optional()` whenever a default is\n // present (matches the existing non-reusable behaviour at line ~932).\n if (!refRequired && refSchema.nullable) {\n functions.push(['nullish', undefined]);\n } else if (refSchema.nullable) {\n functions.push(['nullable', undefined]);\n } else if (!refRequired && !refHasDefault) {\n functions.push(['optional', undefined]);\n }\n\n // .default(...) — emit a const for non-primitive defaults. Use the same\n // constNameRegistry-based suffix that the rest of the generator uses so\n // multiple defaults sharing `name` don't collide on `<name>Default`.\n if (refHasDefault) {\n const registry = rules.constNameRegistry ?? {};\n const counter = isNumber(registry[name]) ? registry[name] + 1 : 0;\n registry[name] = counter;\n const suffix = counter ? pascal(getNumberWord(counter)) : '';\n const defaultVarName = `${name}Default${suffix}`;\n const defaultLiteral = stringify(refSchema.default);\n if (defaultLiteral !== undefined) {\n consts.push(`export const ${defaultVarName} = ${defaultLiteral};`);\n functions.push(['default', defaultVarName]);\n }\n }\n\n // .describe('...')\n if (typeof refSchema.description === 'string') {\n functions.push(['describe', `\"${escape(refSchema.description)}\"`]);\n }\n\n return { functions, consts };\n }\n\n // Non-chainable sibling present — fall back to inlining at this site only.\n // We reassign the local `schema` reference to the dereferenced form and let\n // the rest of the function process it normally.\n logVerbose(\n `[orval/zod] $ref ${schema.$ref} has non-chainable siblings ` +\n `[${siblings.filter((s) => !isChainable(s)).join(', ')}]; falling back to inlining.`,\n );\n schema = dereference(\n schema as OpenApiSchemaObject | OpenApiReferenceObject,\n context,\n );\n }\n\n const useReusableSchemas = rules?.useReusableSchemas ?? false;\n const consts: string[] = [];\n const constNameRegistry = rules?.constNameRegistry ?? {};\n const constsCounter = isNumber(constNameRegistry[name])\n ? constNameRegistry[name] + 1\n : 0;\n\n const constsCounterValue = constsCounter\n ? pascal(getNumberWord(constsCounter))\n : '';\n\n constNameRegistry[name] = constsCounter;\n\n const functions: [string, unknown][] = [];\n const type = resolveZodType(schema);\n const required = rules?.required ?? false;\n const hasDefault = schema.default !== undefined;\n const nullable =\n // changing to ?? here changes behavior - so don't\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n ('nullable' in schema && schema.nullable) ||\n (Array.isArray(schema.type) && schema.type.includes('null'));\n const min = schema.minimum ?? schema.minLength ?? schema.minItems;\n const max = schema.maximum ?? schema.maxLength ?? schema.maxItems;\n\n // Handle exclusiveMinimum and exclusiveMaximum (OpenAPI 3.0 vs 3.1 compatibility)\n // OpenAPI 3.0: exclusiveMinimum/exclusiveMaximum are booleans indicating if minimum/maximum is exclusive\n // OpenAPI 3.1: exclusiveMinimum/exclusiveMaximum are numbers (the value itself)\n const exclusiveMinRaw =\n 'exclusiveMinimum' in schema ? schema.exclusiveMinimum : undefined;\n const exclusiveMaxRaw =\n 'exclusiveMaximum' in schema ? schema.exclusiveMaximum : undefined;\n\n // Convert boolean to number if using OpenAPI 3.0 format\n const exclusiveMin =\n isBoolean(exclusiveMinRaw) && exclusiveMinRaw ? min : exclusiveMinRaw;\n const exclusiveMax =\n isBoolean(exclusiveMaxRaw) && exclusiveMaxRaw ? max : exclusiveMaxRaw;\n\n const multipleOf = schema.multipleOf;\n const matches = schema.pattern ?? undefined;\n // Enum-based schemas are emitted as `zod.enum(...)` or literal unions, so\n // chaining scalar constraints onto the parent schema would generate invalid\n // Zod output. Arrays are handled separately via their item schema.\n const hasNonArrayEnum = !!schema.enum && type !== 'array';\n\n // Check for allOf/oneOf/anyOf BEFORE processing by type\n // This ensures these constraints work with any base type (string, number, object, etc.)\n let skipSwitchStatement = false;\n if (schema.allOf || schema.oneOf || schema.anyOf) {\n const separator = schema.allOf ? 'allOf' : schema.oneOf ? 'oneOf' : 'anyOf';\n\n const schemas = (schema.allOf ?? schema.oneOf ?? schema.anyOf) as (\n | OpenApiSchemaObject\n | OpenApiReferenceObject\n )[];\n\n // Use index-based naming to ensure uniqueness when processing multiple schemas\n // This prevents duplicate schema names when nullable refs are used\n const baseSchemas = schemas.map((schema, index) =>\n generateZodValidationSchemaDefinition(\n schema as OpenApiSchemaObject,\n context,\n `${camel(name)}${pascal(getNumberWord(index + 1))}`,\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n );\n\n // Handle allOf/oneOf/anyOf with additional properties - merge additional properties into the schema\n if ((schema.allOf || schema.oneOf || schema.anyOf) && schema.properties) {\n const additionalPropertiesSchema = {\n properties: schema.properties,\n required: schema.required,\n additionalProperties: schema.additionalProperties,\n type: schema.type,\n } as OpenApiSchemaObject;\n\n // Use index-based naming to ensure uniqueness\n const additionalIndex = baseSchemas.length + 1;\n const additionalPropertiesDefinition =\n generateZodValidationSchemaDefinition(\n additionalPropertiesSchema,\n context,\n `${camel(name)}${pascal(getNumberWord(additionalIndex))}`,\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n );\n\n // For oneOf/anyOf, use allOf to combine union with common properties\n // This generates: zod.union([...]).and(commonProperties)\n if (schema.oneOf || schema.anyOf) {\n functions.push([\n 'allOf',\n [\n { functions: [[separator, baseSchemas]], consts: [] },\n additionalPropertiesDefinition,\n ],\n ]);\n } else {\n // For allOf, just add to the list\n baseSchemas.push(additionalPropertiesDefinition);\n functions.push([separator, baseSchemas]);\n }\n } else {\n functions.push([separator, baseSchemas]);\n }\n skipSwitchStatement = true;\n }\n\n let defaultVarName: string | undefined;\n if (schema.default !== undefined) {\n defaultVarName = `${name}Default${constsCounterValue}`;\n let defaultValue: string | undefined;\n\n const isDateType =\n schema.type === 'string' &&\n (schema.format === 'date' || schema.format === 'date-time') &&\n context.output.override.useDates;\n\n if (isDateType) {\n // OpenApiSchemaObject defines default as 'any'\n defaultValue = `new Date(\"${escape(schema.default)}\")`;\n } else if (isObject(schema.default)) {\n // Narrow string literals individually with `as const` so `zod.enum([...])`\n // properties accept the emitted default (#3244). Whole-object/array\n // `as const` would make nested arrays `readonly`, which zod v4's\n // `.default()` rejects against its mutable parameter type (#3399).\n const entries = Object.entries(schema.default)\n .map(([key, value]) => {\n if (isString(value)) {\n return `${key}: \"${escape(value)}\" as const`;\n }\n\n if (Array.isArray(value)) {\n const arrayItems = value.map((item) =>\n isString(item) ? `\"${escape(item)}\" as const` : `${item}`,\n );\n return `${key}: [${arrayItems.join(', ')}]`;\n }\n\n if (\n value === null ||\n value === undefined ||\n isNumber(value) ||\n isBoolean(value)\n )\n return `${key}: ${value}`;\n })\n .join(', ');\n defaultValue = entries.length === 0 ? `{}` : `{ ${entries} }`;\n } else {\n // OpenApiSchemaObject defines default as 'any'\n const rawStringified = stringify(schema.default);\n defaultValue =\n rawStringified === undefined\n ? 'null'\n : rawStringified.replaceAll(\"'\", '`');\n\n // If the schema is an array with enum items, inject inplace to avoid issues with default values\n const isArrayWithEnumItems =\n Array.isArray(schema.default) &&\n type === 'array' &&\n schema.items &&\n 'enum' in schema.items &&\n schema.default.length > 0;\n\n if (isArrayWithEnumItems) {\n defaultVarName = defaultValue;\n defaultValue = undefined;\n }\n }\n if (defaultValue) {\n consts.push(`export const ${defaultVarName} = ${defaultValue};`);\n }\n }\n\n // Handle multi-type schemas (OpenAPI 3.1+ type arrays)\n if (isObject(type) && 'multiType' in type) {\n const types = type.multiType;\n functions.push([\n 'oneOf',\n types.map((t) =>\n generateZodValidationSchemaDefinition(\n {\n ...(schema as Record<string, unknown>),\n type: t,\n } as OpenApiSchemaObject,\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n ),\n ]);\n\n if (!required && nullable) {\n functions.push(['nullish', undefined]);\n } else if (nullable) {\n functions.push(['nullable', undefined]);\n } else if (!required) {\n functions.push(['optional', undefined]);\n }\n\n return { functions, consts };\n }\n\n if (!skipSwitchStatement) {\n switch (type) {\n case 'tuple': {\n /**\n *\n * > 10.3.1.1. prefixItems\n * > The value of \"prefixItems\" MUST be a non-empty array of valid JSON Schemas.\n * >\n * > Validation succeeds if each element of the instance validates against the schema at the same position, if any.\n * > This keyword does not constrain the length of the array. If the array is longer than this keyword's value,\n * > this keyword validates only the prefix of matching length.\n * >\n * > This keyword produces an annotation value which is the largest index to which this keyword applied a subschema.\n * > The value MAY be a boolean true if a subschema was applied to every index of the instance, such as is produced by the \"items\" keyword.\n * > This annotation affects the behavior of \"items\" and \"unevaluatedItems\".\n * >\n * > Omitting this keyword has the same assertion behavior as an empty array.\n */\n if ('prefixItems' in schema) {\n const schema31 = schema as OpenApiSchemaObject;\n const prefixItems = Array.isArray(schema31.prefixItems)\n ? (schema31.prefixItems as (\n | OpenApiSchemaObject\n | OpenApiReferenceObject\n )[])\n : [];\n\n if (prefixItems.length > 0) {\n functions.push([\n 'tuple',\n prefixItems.map((item, idx) =>\n generateZodValidationSchemaDefinition(\n dereference(item, context),\n context,\n camel(`${name}-${idx}-item`),\n isZodV4,\n strict,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n ),\n ]);\n\n if (\n schema.items &&\n (max ?? Number.POSITIVE_INFINITY) > prefixItems.length\n ) {\n // only add zod.rest() if number of tuple elements can exceed provided prefixItems:\n functions.push([\n 'rest',\n generateZodValidationSchemaDefinition(\n schema.items as OpenApiSchemaObject | undefined,\n context,\n camel(`${name}-item`),\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n ]);\n }\n }\n }\n break;\n }\n case 'array': {\n functions.push([\n 'array',\n generateZodValidationSchemaDefinition(\n schema.items as OpenApiSchemaObject | undefined,\n context,\n camel(`${name}-item`),\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n ]);\n break;\n }\n case 'string': {\n if (schema.enum) {\n break;\n }\n\n if (\n context.output.override.useDates &&\n (schema.format === 'date' || schema.format === 'date-time')\n ) {\n functions.push(['date', undefined]);\n break;\n }\n\n if (schema.format === 'binary') {\n functions.push(['instanceof', 'File']);\n break;\n }\n\n // The @scalar/openapi-parser upgrader converts format: binary to\n // contentMediaType: application/octet-stream when upgrading\n // Swagger 2.0 / OAS 3.0 → OAS 3.1. Treat it the same as\n // format: binary so $ref-based model types generate File validation.\n if (\n schema.contentMediaType === 'application/octet-stream' &&\n !schema.contentEncoding\n ) {\n functions.push(['instanceof', 'File']);\n break;\n }\n\n if (isZodV4) {\n if (!predefinedZodFormats.has(schema.format ?? '')) {\n if ('const' in schema) {\n functions.push(['literal', `\"${schema.const}\"`]);\n } else if (schema.pattern && schema.format) {\n const isStartWithSlash = schema.pattern.startsWith('/');\n const isEndWithSlash = schema.pattern.endsWith('/');\n const regexp = `new RegExp('${jsStringEscape(\n schema.pattern.slice(\n isStartWithSlash ? 1 : 0,\n isEndWithSlash ? -1 : undefined,\n ),\n )}')`;\n consts.push(\n `export const ${name}RegExp${constsCounterValue} = ${regexp};\\n`,\n );\n functions.push([\n 'stringFormat',\n [\n `'${escape(schema.format)}'`,\n `${name}RegExp${constsCounterValue}`,\n ],\n ]);\n } else {\n functions.push([type as string, undefined]);\n }\n break;\n }\n } else {\n if ('const' in schema) {\n functions.push(['literal', `\"${schema.const}\"`]);\n } else {\n functions.push([type as string, undefined]);\n }\n }\n\n if (schema.format === 'date') {\n const formatAPI = getZodDateFormat(isZodV4);\n\n functions.push([formatAPI, undefined]);\n break;\n }\n\n if (schema.format === 'time') {\n const options = context.output.override.zod.timeOptions;\n const formatAPI = getZodTimeFormat(isZodV4);\n\n functions.push([formatAPI, JSON.stringify(options)]);\n break;\n }\n\n if (schema.format === 'date-time') {\n const options = context.output.override.zod.dateTimeOptions;\n const formatAPI = getZodDateTimeFormat(isZodV4);\n\n functions.push([formatAPI, JSON.stringify(options)]);\n break;\n }\n\n if (schema.format === 'email') {\n functions.push(['email', undefined]);\n break;\n }\n\n if (schema.format === 'uri') {\n functions.push(['url', undefined]);\n break;\n }\n\n if (schema.format === 'hostname') {\n if (isZodV4) {\n functions.push(['hostname', undefined]);\n } else {\n functions.push(['url', undefined]);\n }\n break;\n }\n\n if (schema.format === 'uuid') {\n functions.push(['uuid', undefined]);\n break;\n }\n\n break;\n }\n default: {\n const hasProperties = !!schema.properties;\n const properties = schema.properties ?? {};\n const hasDefinedProperties = Object.keys(properties).length > 0;\n const hasAdditionalPropertiesSchema =\n !!schema.additionalProperties &&\n !isBoolean(schema.additionalProperties);\n\n // A plain `type: object` without explicit properties/additionalProperties\n // represents an open dictionary-like object in OpenAPI and should not be\n // generated as a strict object.\n const shouldUseLooseObject =\n type === 'object' &&\n !hasDefinedProperties &&\n schema.additionalProperties === undefined &&\n !hasAdditionalPropertiesSchema;\n\n if (hasProperties && hasDefinedProperties) {\n const objectType = getObjectFunctionName(isZodV4, strict);\n\n functions.push([\n objectType,\n Object.keys(properties)\n .map((key) => ({\n [key]:\n rules?.propertyOverrides?.[key] ??\n generateZodValidationSchemaDefinition(\n properties[key] as OpenApiSchemaObject | undefined,\n context,\n camel(`${name}-${key}`),\n strict,\n isZodV4,\n {\n required: schema.required?.includes(key),\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n }))\n .reduce((acc, curr) => ({ ...acc, ...curr }), {}),\n ]);\n\n if (strict && !isZodV4) {\n functions.push(['strict', undefined]);\n }\n\n break;\n }\n\n if (shouldUseLooseObject) {\n const looseObjectType = getLooseObjectFunctionName(isZodV4);\n\n functions.push([looseObjectType, {}]);\n\n if (!isZodV4) {\n functions.push(['passthrough', undefined]);\n }\n\n break;\n }\n\n if (schema.additionalProperties) {\n functions.push([\n 'additionalProperties',\n generateZodValidationSchemaDefinition(\n isBoolean(schema.additionalProperties)\n ? {}\n : (schema.additionalProperties as OpenApiSchemaObject),\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n ]);\n\n break;\n }\n\n if (schema.enum) {\n break;\n }\n\n functions.push([type, undefined]);\n\n break;\n }\n }\n }\n\n if (!hasNonArrayEnum && isString(type) && minAndMaxTypes.has(type)) {\n // Handle minimum constraints: exclusiveMinimum (>.gt()) takes priority over minimum (.min())\n // Check if exclusive flag was set (boolean format in OpenAPI 3.0) or a different value (OpenAPI 3.1)\n const shouldUseExclusiveMin = exclusiveMinRaw !== undefined;\n const shouldUseExclusiveMax = exclusiveMaxRaw !== undefined;\n\n if (shouldUseExclusiveMin && exclusiveMin !== undefined) {\n consts.push(\n `export const ${name}ExclusiveMin${constsCounterValue} = ${exclusiveMin};`,\n );\n // Generate .gt() for exclusive minimum (> instead of >=)\n functions.push(['gt', `${name}ExclusiveMin${constsCounterValue}`]);\n } else if (min !== undefined) {\n if (min === 1) {\n functions.push(['min', `${min}`]);\n } else {\n consts.push(`export const ${name}Min${constsCounterValue} = ${min};`);\n functions.push(['min', `${name}Min${constsCounterValue}`]);\n }\n }\n\n // Handle maximum constraints: exclusiveMaximum (<.lt()) takes priority over maximum (.max())\n if (shouldUseExclusiveMax && exclusiveMax !== undefined) {\n consts.push(\n `export const ${name}ExclusiveMax${constsCounterValue} = ${exclusiveMax};`,\n );\n // Generate .lt() for exclusive maximum (< instead of <=)\n functions.push(['lt', `${name}ExclusiveMax${constsCounterValue}`]);\n } else if (max !== undefined) {\n consts.push(`export const ${name}Max${constsCounterValue} = ${max};`);\n functions.push(['max', `${name}Max${constsCounterValue}`]);\n }\n\n if (multipleOf !== undefined) {\n consts.push(\n `export const ${name}MultipleOf${constsCounterValue} = ${multipleOf.toString()};`,\n );\n functions.push(['multipleOf', `${name}MultipleOf${constsCounterValue}`]);\n }\n if (\n exclusiveMin !== undefined ||\n min !== undefined ||\n exclusiveMax !== undefined ||\n multipleOf !== undefined ||\n max !== undefined\n ) {\n consts.push(`\\n`);\n }\n }\n\n const stringFormatAlreadyEmitted =\n isZodV4 &&\n type === 'string' &&\n !!matches &&\n !!schema.format &&\n !predefinedZodFormats.has(schema.format ?? '');\n\n if (\n matches &&\n !hasNonArrayEnum &&\n type === 'string' &&\n !stringFormatAlreadyEmitted\n ) {\n const isStartWithSlash = matches.startsWith('/');\n const isEndWithSlash = matches.endsWith('/');\n\n const regexp = `new RegExp('${jsStringEscape(\n matches.slice(isStartWithSlash ? 1 : 0, isEndWithSlash ? -1 : undefined),\n )}')`;\n\n consts.push(\n `export const ${name}RegExp${constsCounterValue} = ${regexp};\\n`,\n );\n if (schema.format && !predefinedZodFormats.has(schema.format) && isZodV4) {\n functions.push([\n 'stringFormat',\n [`'${escape(schema.format)}'`, `${name}RegExp${constsCounterValue}`],\n ]);\n } else {\n functions.push(['regex', `${name}RegExp${constsCounterValue}`]);\n }\n }\n\n // Array item enums are handled by the nested item schema. Guard parent-array\n // enum emission to avoid generating invalid trailing `.enum(...)` chains.\n if (schema.enum && type !== 'array') {\n const uniqueEnumValues = unique(schema.enum);\n\n if (uniqueEnumValues.every((value) => isString(value))) {\n functions.push([\n 'enum',\n `[${uniqueEnumValues.map((value) => `'${escape(value)}'`).join(', ')}]`,\n ]);\n } else {\n functions.push([\n 'oneOf',\n uniqueEnumValues.map((value) => ({\n functions: [\n ['literal', isString(value) ? `'${escape(value)}'` : value],\n ],\n consts: [],\n })),\n ]);\n }\n }\n\n if (!required && nullable) {\n functions.push(['nullish', undefined]);\n } else if (nullable) {\n functions.push(['nullable', undefined]);\n } else if (!required && !hasDefault) {\n functions.push(['optional', undefined]);\n }\n\n if (hasDefault) {\n functions.push(['default', defaultVarName]);\n }\n\n if (schema.description) {\n functions.push(['describe', `'${jsStringEscape(schema.description)}'`]);\n }\n\n return { functions, consts: unique(consts) };\n};\n\nexport const parseZodValidationSchemaDefinition = (\n input: ZodValidationSchemaDefinition,\n context: ContextSpec,\n coerceTypes: boolean | ZodCoerceType[] = false,\n strict: boolean,\n isZodV4: boolean,\n preprocess?: GeneratorMutator,\n): { zod: string; consts: string; usedRefs: Set<string> } => {\n if (input.functions.length === 0) {\n return { zod: '', consts: '', usedRefs: new Set() };\n }\n\n let consts = '';\n const usedRefs = new Set<string>();\n\n const appendConstsChunk = (chunk: string) => {\n if (!chunk) {\n return;\n }\n\n if (\n consts.length > 0 &&\n !consts.endsWith('\\n') &&\n !chunk.startsWith('\\n')\n ) {\n consts += '\\n';\n }\n\n consts += chunk;\n };\n\n const formatFunctionArgs = (value: unknown): string => {\n if (value === undefined) return '';\n if (value === null) return 'null';\n if (isString(value)) return value;\n if (Array.isArray(value)) {\n return value.map((item) => formatFunctionArgs(item)).join(', ');\n }\n if (isObject(value)) {\n return stringify(value) ?? '';\n }\n if (isNumber(value) || isBoolean(value)) return `${value}`;\n return '';\n };\n\n const parseProperty = (property: [string, unknown]): string => {\n const [fn, args = ''] = property;\n\n if (fn === 'namedRef') {\n const refArgs = args as { name: string; sourceRef: string };\n usedRefs.add(refArgs.name);\n return `__REF_${refArgs.name}__`;\n }\n\n // File | string for text contentMediaType/encoding (user can pass string, runtime wraps in Blob)\n if (fn === 'fileOrString') {\n return 'zod.instanceof(File).or(zod.string())';\n }\n\n if (fn === 'allOf') {\n const allOfArgs = args as ZodValidationSchemaDefinition[];\n // Check if all parts are objects and we need to merge them for strict mode\n const allAreObjects =\n strict &&\n allOfArgs.length > 0 &&\n allOfArgs.every((partSchema) => {\n if (partSchema.functions.length === 0) return false;\n const firstFn = partSchema.functions[0][0];\n // Check if first function is object or strictObject\n // For Zod v3 with strict, it will be object followed by strict\n return firstFn === 'object' || firstFn === 'strictObject';\n });\n\n if (allAreObjects) {\n // Merge all object properties into a single object\n const mergedProperties: Record<string, ZodValidationSchemaDefinition> =\n {};\n let allConsts = '';\n\n for (const partSchema of allOfArgs) {\n if (partSchema.consts.length > 0) {\n allConsts += partSchema.consts.join('\\n');\n }\n\n // Find the object function (might be first or second after strict)\n const objectFunctionIndex = partSchema.functions.findIndex(\n ([fnName]) => fnName === 'object' || fnName === 'strictObject',\n );\n\n if (objectFunctionIndex !== -1) {\n const objectArgs = partSchema.functions[objectFunctionIndex][1];\n if (isObject(objectArgs)) {\n // Merge properties (later schemas override earlier ones)\n Object.assign(\n mergedProperties,\n objectArgs as Record<string, ZodValidationSchemaDefinition>,\n );\n }\n }\n }\n\n if (allConsts.length > 0) {\n appendConstsChunk(allConsts);\n }\n\n // Generate merged object\n const objectType = getObjectFunctionName(isZodV4, strict);\n const mergedObjectString = `zod.${objectType}({\n${Object.entries(mergedProperties)\n .map(([key, schema]) => {\n const value = schema.functions.map((prop) => parseProperty(prop)).join('');\n appendConstsChunk(schema.consts.join('\\n'));\n return ` \"${key}\": ${value.startsWith('.') ? 'zod' : ''}${value}`;\n })\n .join(',\\n')}\n})`;\n\n // Apply strict only once for Zod v3 (v4 uses strictObject)\n if (!isZodV4) {\n return `${mergedObjectString}.strict()`;\n }\n\n return mergedObjectString;\n }\n\n // Fallback to original .and() approach for non-object or non-strict cases\n let acc = '';\n for (const partSchema of allOfArgs) {\n const value = partSchema.functions\n .map((prop) => parseProperty(prop))\n .join('');\n const valueWithZod = `${value.startsWith('.') ? 'zod' : ''}${value}`;\n\n if (partSchema.consts.length > 0) {\n appendConstsChunk(partSchema.consts.join('\\n'));\n }\n\n if (acc.length === 0) {\n acc = valueWithZod;\n } else {\n acc += `.and(${valueWithZod})`;\n }\n }\n\n return acc;\n }\n if (fn === 'oneOf' || fn === 'anyOf') {\n const unionArgs = args as ZodValidationSchemaDefinition[];\n // Can't use zod.union() with a single item\n if (unionArgs.length === 1) {\n return unionArgs[0].functions\n .map((prop: [string, unknown]) => parseProperty(prop))\n .join('');\n }\n\n const union = unionArgs.map(\n ({\n functions,\n consts: argConsts,\n }: {\n functions: [string, unknown][];\n consts: string[];\n }) => {\n const value = functions.map((prop) => parseProperty(prop)).join('');\n const valueWithZod = `${value.startsWith('.') ? 'zod' : ''}${value}`;\n // consts are missing here\n appendConstsChunk(argConsts.join('\\n'));\n return valueWithZod;\n },\n );\n\n return `.union([${union.join(',')}])`;\n }\n\n if (fn === 'additionalProperties') {\n const additionalPropertiesArgs = args as ZodValidationSchemaDefinition;\n const value = additionalPropertiesArgs.functions\n .map((prop: [string, unknown]) => parseProperty(prop))\n .join('');\n const valueWithZod = `${value.startsWith('.') ? 'zod' : ''}${value}`;\n if (Array.isArray(additionalPropertiesArgs.consts)) {\n appendConstsChunk(additionalPropertiesArgs.consts.join('\\n'));\n }\n return `zod.record(zod.string(), ${valueWithZod})`;\n }\n\n if (fn === 'object' || fn === 'strictObject' || fn === 'looseObject') {\n const objectArgs = args as Record<string, ZodValidationSchemaDefinition>;\n const objectType =\n fn === 'looseObject'\n ? isZodV4\n ? 'looseObject'\n : 'object'\n : getObjectFunctionName(isZodV4, strict);\n\n const parsedObject = `zod.${objectType}({\n${Object.entries(objectArgs)\n .map(([key, schema]) => {\n const value = schema.functions.map((prop) => parseProperty(prop)).join('');\n appendConstsChunk(schema.consts.join('\\n'));\n return ` \"${key}\": ${value.startsWith('.') ? 'zod' : ''}${value}`;\n })\n .join(',\\n')}\n})`;\n\n if (fn === 'looseObject' && !isZodV4) {\n return `${parsedObject}.passthrough()`;\n }\n\n return parsedObject;\n }\n\n if (fn === 'passthrough') {\n return '.passthrough()';\n }\n\n if (fn === 'array') {\n const arrayArgs = args as ZodValidationSchemaDefinition;\n const value = arrayArgs.functions\n .map((prop: [string, unknown]) => parseProperty(prop))\n .join('');\n if (isString(arrayArgs.consts)) {\n appendConstsChunk(arrayArgs.consts);\n } else if (Array.isArray(arrayArgs.consts)) {\n appendConstsChunk(arrayArgs.consts.join('\\n'));\n }\n return `.array(${value.startsWith('.') ? 'zod' : ''}${value})`;\n }\n\n if (fn === 'strict' && !isZodV4) {\n return '.strict()';\n }\n\n if (fn === 'tuple') {\n return `zod.tuple([${(args as ZodValidationSchemaDefinition[])\n .map((x) => {\n const value = x.functions.map((prop) => parseProperty(prop)).join('');\n return `${value.startsWith('.') ? 'zod' : ''}${value}`;\n })\n .join(',\\n')}])`;\n }\n if (fn === 'rest') {\n return `.rest(zod${(args as ZodValidationSchemaDefinition).functions\n .map((prop) => parseProperty(prop))\n .join('')})`;\n }\n const shouldCoerceType =\n coerceTypes &&\n (Array.isArray(coerceTypes)\n ? coerceTypes.includes(fn as ZodCoerceType)\n : COERCIBLE_TYPES.has(fn));\n\n if (\n (fn !== 'date' && shouldCoerceType) ||\n (fn === 'date' && shouldCoerceType && context.output.override.useDates)\n ) {\n return `.coerce.${fn}(${formatFunctionArgs(args)})`;\n }\n\n return `.${fn}(${formatFunctionArgs(args)})`;\n };\n\n appendConstsChunk(input.consts.join('\\n'));\n\n const schema = input.functions.map((prop) => parseProperty(prop)).join('');\n const value = preprocess\n ? `.preprocess(${preprocess.name}, ${\n schema.startsWith('.') ? 'zod' : ''\n }${schema})`\n : schema;\n\n const zod = `${value.startsWith('.') ? 'zod' : ''}${value}`;\n // Some export consts includes `,` as prefix, adding replace to remove those\n if (consts.includes(',export')) {\n consts = consts.replaceAll(',export', '\\nexport');\n }\n return { zod, consts, usedRefs };\n};\n\nconst dereferenceScalar = (value: unknown, context: ContextSpec): unknown => {\n if (isObject(value)) {\n return dereference(\n value as OpenApiSchemaObject | OpenApiReferenceObject,\n context,\n );\n } else if (Array.isArray(value)) {\n return value.map((item) => dereferenceScalar(item, context));\n } else {\n return value;\n }\n};\n\n/**\n * Attempts to resolve a `$ref` to its target schema. Returns `undefined`\n * instead of throwing when the ref cannot be found (e.g. external refs\n * not yet bundled). Logs a verbose warning on failure to aid debugging.\n */\nfunction tryResolveRefSchema(\n $ref: string,\n context: ContextSpec,\n): OpenApiSchemaObject | undefined {\n try {\n return resolveRef({ $ref } as OpenApiReferenceObject, context)\n .schema as OpenApiSchemaObject;\n } catch (error) {\n logVerbose(\n `[orval/zod] Failed to resolve $ref \"${$ref}\":`,\n error instanceof Error ? error.message : error,\n );\n return;\n }\n}\n\n/**\n * Recursively inlines all `$ref` references in an OpenAPI schema tree,\n * producing a fully-resolved schema suitable for Zod code generation.\n *\n * Tracks visited `$ref` paths via `context.parents` to break circular\n * references (returning `{}` for cycles).\n */\nexport const dereference = (\n schema: OpenApiSchemaObject | OpenApiReferenceObject,\n context: ContextSpec,\n): OpenApiSchemaObject => {\n const refName = '$ref' in schema ? schema.$ref : undefined;\n if (refName && context.parents?.includes(refName)) {\n return {};\n }\n\n const childContext: ContextSpec = {\n ...context,\n ...(refName\n ? { parents: [...(context.parents ?? []), refName] }\n : undefined),\n };\n\n const resolvedSchema: OpenApiSchemaObject | undefined =\n '$ref' in schema\n ? (() => {\n const referencedSchema = tryResolveRefSchema(schema.$ref, context);\n\n if (!referencedSchema || !isObject(referencedSchema)) {\n return;\n }\n\n const siblingProperties = Object.fromEntries(\n Object.entries(schema as Record<string, unknown>).filter(\n ([key]) => key !== '$ref',\n ),\n );\n\n return {\n ...(referencedSchema as Record<string, unknown>),\n ...siblingProperties,\n } as OpenApiSchemaObject;\n })()\n : schema;\n\n if (!resolvedSchema) {\n return {};\n }\n\n const resolvedContext = childContext;\n\n return Object.entries(resolvedSchema).reduce<Record<string, unknown>>(\n (acc, [key, value]) => {\n if (key === 'properties' && isObject(value)) {\n acc[key] = Object.entries(value).reduce<\n Record<string, OpenApiSchemaObject>\n >((props, [propKey, propSchema]) => {\n props[propKey] = dereference(\n propSchema as OpenApiSchemaObject | OpenApiReferenceObject,\n resolvedContext,\n );\n return props;\n }, {});\n } else if (key === 'default' || key === 'example' || key === 'examples') {\n acc[key] = value;\n } else {\n acc[key] = dereferenceScalar(value, resolvedContext);\n }\n\n return acc;\n },\n {},\n ) as OpenApiSchemaObject;\n};\n\n/**\n * Generate zod schema for form-data request body.\n * Handles file type detection for top-level properties based on encoding.contentType\n * and contentMediaType. Mirrors type gen's resolveFormDataRootObject.\n */\nexport const generateFormDataZodSchema = (\n schema: OpenApiSchemaObject,\n context: ContextSpec,\n name: string,\n strict: boolean,\n isZodV4: boolean,\n encoding?: Record<string, { contentType?: string }>,\n useReusableSchemas?: boolean,\n): ZodValidationSchemaDefinition => {\n // Precompute file type overrides for top-level properties only\n const propertyOverrides: Record<string, ZodValidationSchemaDefinition> = {};\n\n if (schema.properties) {\n for (const key of Object.keys(schema.properties)) {\n const propSchema = schema.properties[key];\n const resolvedPropSchema = propSchema\n ? dereference(\n propSchema as OpenApiSchemaObject | OpenApiReferenceObject,\n context,\n )\n : undefined;\n\n const fileType = resolvedPropSchema\n ? getFormDataFieldFileType(\n resolvedPropSchema,\n encoding?.[key]?.contentType,\n )\n : undefined;\n\n if (fileType) {\n const isRequired = schema.required?.includes(key);\n const fileFunctions: [string, unknown][] = [\n fileType === 'binary'\n ? ['instanceof', 'File']\n : ['fileOrString', undefined],\n ];\n if (!isRequired) {\n fileFunctions.push(['optional', undefined]);\n }\n propertyOverrides[key] = { functions: fileFunctions, consts: [] };\n }\n }\n }\n\n // Delegate to generic handler with file type overrides\n return generateZodValidationSchemaDefinition(\n schema,\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n propertyOverrides:\n Object.keys(propertyOverrides).length > 0\n ? propertyOverrides\n : undefined,\n useReusableSchemas,\n },\n );\n};\n\nconst parseBodyAndResponse = ({\n data,\n context,\n name,\n strict,\n generate,\n isZodV4,\n parseType,\n useReusableSchemas,\n}: {\n data:\n | OpenApiResponseObject\n | OpenApiRequestBodyObject\n | OpenApiReferenceObject\n | undefined;\n context: ContextSpec;\n name: string;\n strict: boolean;\n generate: boolean;\n isZodV4: boolean;\n parseType: 'body' | 'response';\n useReusableSchemas?: boolean;\n}): {\n input: ZodValidationSchemaDefinition;\n isArray: boolean;\n rules?: {\n min?: number;\n max?: number;\n };\n} => {\n if (!data || !generate) {\n return {\n input: { functions: [], consts: [] },\n isArray: false,\n };\n }\n\n const resolvedRef = resolveRef(data, context).schema as\n | OpenApiResponseObject\n | OpenApiRequestBodyObject;\n\n // Only handle JSON and form-data; other content types (e.g., application/octet-stream)\n // Only handle JSON and form-data; other content types (e.g., application/octet-stream)\n // are skipped - unclear if this is correct behavior for root-level binary/text bodies.\n const contentEntries = Object.entries(resolvedRef.content ?? {});\n\n const jsonContent = contentEntries.find(\n isMediaType(\n // application/json\n // application/geo+json\n // application/ld+json\n // application/manifest+json\n // application/vnd.api+json (and other valid vendor subtypes)\n String.raw`^application\\/([^/;]+\\+)?json$`,\n ),\n );\n const formDataContent = contentEntries.find(\n isMediaType(String.raw`^multipart\\/form-data$`),\n );\n const [contentType, mediaType] = jsonContent\n ? (['application/json', jsonContent[1]] as const)\n : formDataContent\n ? (['multipart/form-data', formDataContent[1]] as const)\n : [undefined, undefined];\n\n const schema = mediaType?.schema;\n\n if (!schema) {\n return {\n input: { functions: [], consts: [] },\n isArray: false,\n };\n }\n const encoding = mediaType.encoding;\n\n const resolvedJsonSchema = dereference(schema, context);\n\n // keep the same behaviour for array\n if (resolvedJsonSchema.items) {\n const min =\n resolvedJsonSchema.minimum ??\n resolvedJsonSchema.minLength ??\n resolvedJsonSchema.minItems;\n const max =\n resolvedJsonSchema.maximum ??\n resolvedJsonSchema.maxLength ??\n resolvedJsonSchema.maxItems;\n\n // When useReusableSchemas is on, shallow-resolve one level so that $ref\n // references inside the items schema are preserved for named-ref emission.\n // E.g. Pets = array of {$ref: Pet} → we want to emit Pet (namedRef)\n // rather than inlining Pet's full schema.\n const rawItems: OpenApiSchemaObject | OpenApiReferenceObject =\n useReusableSchemas\n ? (() => {\n const shallowArraySchema = resolveRef(schema, context)\n .schema as OpenApiSchemaObject;\n return (shallowArraySchema.items ??\n resolvedJsonSchema.items) as OpenApiSchemaObject;\n })()\n : resolvedJsonSchema.items;\n\n return {\n input: generateZodValidationSchemaDefinition(\n parseType === 'body'\n ? removeReadOnlyProperties(rawItems as OpenApiSchemaObject)\n : (rawItems as OpenApiSchemaObject),\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n useReusableSchemas,\n },\n ),\n isArray: true,\n rules: {\n ...(min === undefined ? {} : { min }),\n ...(max === undefined ? {} : { max }),\n },\n };\n }\n\n // When useReusableSchemas is on, pass the original schema (possibly a $ref)\n // directly to generateZodValidationSchemaDefinition so that component schema\n // references are emitted as named identifiers instead of being inlined.\n const effectiveSchema: OpenApiSchemaObject | OpenApiReferenceObject =\n useReusableSchemas\n ? parseType === 'body'\n ? removeReadOnlyProperties(schema as OpenApiSchemaObject)\n : schema\n : parseType === 'body'\n ? removeReadOnlyProperties(resolvedJsonSchema)\n : resolvedJsonSchema;\n\n const isFormData = contentType === 'multipart/form-data';\n\n return {\n input: isFormData\n ? generateFormDataZodSchema(\n effectiveSchema,\n context,\n name,\n strict,\n isZodV4,\n encoding,\n useReusableSchemas,\n )\n : generateZodValidationSchemaDefinition(\n effectiveSchema,\n context,\n name,\n strict,\n isZodV4,\n { required: true, useReusableSchemas },\n ),\n isArray: false,\n };\n};\n\nconst isMediaType =\n (pattern: string) =>\n ([contentType]: [string, object]): boolean =>\n new RegExp(pattern).test(contentType.split(';')[0].trim().toLowerCase());\n\nconst getSingleResponse = (\n responses:\n | Record<string, OpenApiResponseObject | OpenApiReferenceObject | undefined>\n | undefined,\n) => {\n if (!responses) {\n return;\n }\n\n return responses['200'] ?? responses['2XX'] ?? responses['2xx'];\n};\n\n/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */\n\nexport const parseParameters = ({\n data,\n context,\n operationName,\n isZodV4,\n strict,\n generate,\n useReusableSchemas,\n}: {\n data: (OpenApiParameterObject | OpenApiReferenceObject)[] | undefined;\n context: ContextSpec;\n operationName: string;\n isZodV4: boolean;\n strict: {\n param: boolean;\n query: boolean;\n header: boolean;\n body: boolean;\n response: boolean;\n };\n generate: {\n param: boolean;\n query: boolean;\n header: boolean;\n body: boolean;\n response: boolean;\n };\n useReusableSchemas?: boolean;\n}): {\n headers: ZodValidationSchemaDefinition;\n queryParams: ZodValidationSchemaDefinition;\n params: ZodValidationSchemaDefinition;\n} => {\n if (!data) {\n return {\n headers: {\n functions: [],\n consts: [],\n },\n queryParams: {\n functions: [],\n consts: [],\n },\n params: {\n functions: [],\n consts: [],\n },\n };\n }\n\n const initialDefinitionsByParameters: Record<\n 'headers' | 'queryParams' | 'params',\n Record<string, { functions: [string, unknown][]; consts: string[] }>\n > = {\n headers: {},\n queryParams: {},\n params: {},\n };\n\n const defintionsByParameters = data.reduce((acc, val) => {\n const { schema: parameter }: { schema: OpenApiParameterObject } =\n resolveRef(val, context);\n\n if (!parameter.schema) {\n return acc;\n }\n if (!parameter.in || !parameter.name) {\n return acc;\n }\n\n // When useReusableSchemas is on, preserve `$ref` schemas verbatim so the\n // generator can take the namedRef path. We only shallow-clone to attach\n // the parameter-level `description` without mutating the shared ref object.\n // When off, fall back to dereferencing for backward compatibility.\n const schemaForGen: OpenApiSchemaObject | OpenApiReferenceObject =\n useReusableSchemas\n ? parameter.description\n ? Object.assign({}, parameter.schema, {\n description: parameter.description,\n })\n : parameter.schema\n : (() => {\n const s = dereference(parameter.schema, context);\n s.description = parameter.description;\n return s;\n })();\n\n const mapStrict = {\n path: strict.param,\n query: strict.query,\n header: strict.header,\n };\n\n const mapGenerate = {\n path: generate.param,\n query: generate.query,\n header: generate.header,\n };\n\n if (\n parameter.in !== 'path' &&\n parameter.in !== 'query' &&\n parameter.in !== 'header'\n ) {\n return acc;\n }\n\n const definition = generateZodValidationSchemaDefinition(\n schemaForGen,\n context,\n camel(`${operationName}-${parameter.in}-${parameter.name}`),\n mapStrict[parameter.in],\n isZodV4,\n {\n required: parameter.required,\n useReusableSchemas,\n },\n );\n\n if (parameter.in === 'header' && mapGenerate.header) {\n return {\n ...acc,\n headers: { ...acc.headers, [parameter.name]: definition },\n };\n }\n\n if (parameter.in === 'query' && mapGenerate.query) {\n return {\n ...acc,\n queryParams: { ...acc.queryParams, [parameter.name]: definition },\n };\n }\n\n if (parameter.in === 'path' && mapGenerate.path) {\n return {\n ...acc,\n params: { ...acc.params, [parameter.name]: definition },\n };\n }\n\n return acc;\n }, initialDefinitionsByParameters);\n\n const headers: ZodValidationSchemaDefinition = {\n functions: [],\n consts: [],\n };\n\n if (Object.keys(defintionsByParameters.headers).length > 0) {\n const parameterFunctions = getParameterFunctions(\n isZodV4,\n strict.header,\n defintionsByParameters.headers,\n );\n\n headers.functions.push(...parameterFunctions);\n }\n\n const queryParams: ZodValidationSchemaDefinition = {\n functions: [],\n consts: [],\n };\n\n if (Object.keys(defintionsByParameters.queryParams).length > 0) {\n const parameterFunctions = getParameterFunctions(\n isZodV4,\n strict.query,\n defintionsByParameters.queryParams,\n );\n\n queryParams.functions.push(...parameterFunctions);\n }\n\n const params: ZodValidationSchemaDefinition = {\n functions: [],\n consts: [],\n };\n\n if (Object.keys(defintionsByParameters.params).length > 0) {\n const parameterFunctions = getParameterFunctions(\n isZodV4,\n strict.param,\n defintionsByParameters.params,\n );\n\n params.functions.push(...parameterFunctions);\n }\n\n return {\n headers,\n queryParams,\n params,\n };\n};\n\nconst generateZodRoute = async (\n { operationName, verb, override }: GeneratorVerbOptions,\n { pathRoute, context, output }: GeneratorOptions,\n) => {\n const isZodV4 =\n !!context.output.packageJson && isZodVersionV4(context.output.packageJson);\n const useReusableSchemas =\n context.output.override.zod.generateReusableSchemas;\n const spec = context.spec.paths?.[pathRoute];\n\n if (spec == undefined) {\n throw new Error(`No such path ${pathRoute} in ${context.projectName}`);\n }\n\n const parameters = [\n ...(spec.parameters ?? []),\n ...(spec[verb]?.parameters ?? []),\n ];\n\n const parsedParameters = parseParameters({\n data: parameters,\n context,\n operationName,\n isZodV4,\n strict: override.zod.strict,\n generate: override.zod.generate,\n useReusableSchemas,\n });\n\n const requestBody = spec[verb]?.requestBody;\n const parsedBody = parseBodyAndResponse({\n data: requestBody,\n context,\n name: camel(`${operationName}-body`),\n strict: override.zod.strict.body,\n generate: override.zod.generate.body,\n isZodV4,\n parseType: 'body',\n useReusableSchemas,\n });\n\n const responses = (\n context.output.override.zod.generateEachHttpStatus\n ? Object.entries(spec[verb]?.responses ?? {})\n : [['', getSingleResponse(spec[verb]?.responses)]]\n ) as [string, OpenApiResponseObject | OpenApiReferenceObject][];\n const parsedResponses = responses.map(([code, response]) =>\n parseBodyAndResponse({\n data: response,\n context,\n name: camel(`${operationName}-${code}-response`),\n strict: override.zod.strict.response,\n generate: override.zod.generate.response,\n isZodV4,\n parseType: 'response',\n useReusableSchemas,\n }),\n );\n\n const preprocessParams = override.zod.preprocess?.param\n ? await generateMutator({\n output,\n mutator: override.zod.preprocess.response,\n name: `${operationName}PreprocessParams`,\n workspace: context.workspace,\n tsconfig: context.output.tsconfig,\n })\n : undefined;\n\n let inputParams = parseZodValidationSchemaDefinition(\n parsedParameters.params,\n context,\n override.zod.coerce.param,\n override.zod.strict.param,\n isZodV4,\n preprocessParams,\n );\n\n const preprocessQueryParams = override.zod.preprocess?.query\n ? await generateMutator({\n output,\n mutator: override.zod.preprocess.response,\n name: `${operationName}PreprocessQueryParams`,\n workspace: context.workspace,\n tsconfig: context.output.tsconfig,\n })\n : undefined;\n\n let inputQueryParams = parseZodValidationSchemaDefinition(\n parsedParameters.queryParams,\n context,\n override.zod.coerce.query,\n override.zod.strict.query,\n isZodV4,\n preprocessQueryParams,\n );\n\n const preprocessHeader = override.zod.preprocess?.header\n ? await generateMutator({\n output,\n mutator: override.zod.preprocess.response,\n name: `${operationName}PreprocessHeader`,\n workspace: context.workspace,\n tsconfig: context.output.tsconfig,\n })\n : undefined;\n\n let inputHeaders = parseZodValidationSchemaDefinition(\n parsedParameters.headers,\n context,\n override.zod.coerce.header,\n override.zod.strict.header,\n isZodV4,\n preprocessHeader,\n );\n\n const preprocessBody = override.zod.preprocess?.body\n ? await generateMutator({\n output,\n mutator: override.zod.preprocess.response,\n name: `${operationName}PreprocessBody`,\n workspace: context.workspace,\n tsconfig: context.output.tsconfig,\n })\n : undefined;\n\n let inputBody = parseZodValidationSchemaDefinition(\n parsedBody.input,\n context,\n override.zod.coerce.body,\n override.zod.strict.body,\n isZodV4,\n preprocessBody,\n );\n\n const preprocessResponse = override.zod.preprocess?.response\n ? await generateMutator({\n output,\n mutator: override.zod.preprocess.response,\n name: `${operationName}PreprocessResponse`,\n workspace: context.workspace,\n tsconfig: context.output.tsconfig,\n })\n : undefined;\n\n const inputResponses = parsedResponses.map((parsedResponse) =>\n parseZodValidationSchemaDefinition(\n parsedResponse.input,\n context,\n override.zod.coerce.response,\n override.zod.strict.response,\n isZodV4,\n preprocessResponse,\n ),\n );\n\n const SENTINEL_PATTERN = /__REF_([A-Za-z_$][A-Za-z0-9_$]*)__/g;\n const rewriteSentinels = (s: string): string =>\n s.replaceAll(SENTINEL_PATTERN, (_m, name: string) => name);\n\n const allUsedRefs = new Set<string>([\n ...inputParams.usedRefs,\n ...inputQueryParams.usedRefs,\n ...inputHeaders.usedRefs,\n ...inputBody.usedRefs,\n ...inputResponses.flatMap((r) => [...r.usedRefs]),\n ]);\n\n if (useReusableSchemas && allUsedRefs.size > 0) {\n inputParams = { ...inputParams, zod: rewriteSentinels(inputParams.zod) };\n inputQueryParams = {\n ...inputQueryParams,\n zod: rewriteSentinels(inputQueryParams.zod),\n };\n inputHeaders = {\n ...inputHeaders,\n zod: rewriteSentinels(inputHeaders.zod),\n };\n inputBody = { ...inputBody, zod: rewriteSentinels(inputBody.zod) };\n for (let i = 0; i < inputResponses.length; i++) {\n inputResponses[i] = {\n ...inputResponses[i],\n zod: rewriteSentinels(inputResponses[i].zod),\n };\n }\n }\n\n if (\n !inputParams.zod &&\n !inputQueryParams.zod &&\n !inputHeaders.zod &&\n !inputBody.zod &&\n !inputResponses.some((inputResponse) => inputResponse.zod)\n ) {\n return {\n implementation: '',\n mutators: [],\n usedRefs: new Set<string>(),\n };\n }\n\n const pascalOperationName = pascal(operationName);\n\n const useBrandedTypes = override.zod.useBrandedTypes;\n const brand = (name: string) =>\n useBrandedTypes\n ? isZodV4\n ? `.brand(\"${name}\")`\n : `.brand<\"${name}\">()`\n : '';\n\n return {\n implementation: [\n ...(inputParams.consts ? [inputParams.consts] : []),\n ...(inputParams.zod\n ? [\n `export const ${pascalOperationName}Params = ${inputParams.zod}${brand(`${pascalOperationName}Params`)}`,\n ]\n : []),\n ...(inputQueryParams.consts ? [inputQueryParams.consts] : []),\n ...(inputQueryParams.zod\n ? [\n `export const ${pascalOperationName}QueryParams = ${inputQueryParams.zod}${brand(`${pascalOperationName}QueryParams`)}`,\n ]\n : []),\n ...(inputHeaders.consts ? [inputHeaders.consts] : []),\n ...(inputHeaders.zod\n ? [\n `export const ${pascalOperationName}Header = ${inputHeaders.zod}${brand(`${pascalOperationName}Header`)}`,\n ]\n : []),\n ...(inputBody.consts ? [inputBody.consts] : []),\n ...(inputBody.zod\n ? [\n parsedBody.isArray\n ? `export const ${pascalOperationName}BodyItem = ${inputBody.zod}\nexport const ${pascalOperationName}Body = zod.array(${pascalOperationName}BodyItem)${\n parsedBody.rules?.min ? `.min(${parsedBody.rules.min})` : ''\n }${\n parsedBody.rules?.max ? `.max(${parsedBody.rules.max})` : ''\n }${brand(`${pascalOperationName}Body`)}`\n : `export const ${pascalOperationName}Body = ${inputBody.zod}${brand(`${pascalOperationName}Body`)}`,\n ]\n : []),\n ...inputResponses.flatMap((inputResponse, index) => {\n const operationResponse = pascal(\n `${operationName}-${responses[index][0]}-response`,\n );\n return [\n ...(inputResponse.consts ? [inputResponse.consts] : []),\n ...(inputResponse.zod\n ? [\n parsedResponses[index].isArray\n ? `export const ${operationResponse}Item = ${\n inputResponse.zod\n }\nexport const ${operationResponse} = zod.array(${operationResponse}Item)${\n parsedResponses[index].rules?.min\n ? `.min(${parsedResponses[index].rules.min})`\n : ''\n }${\n parsedResponses[index].rules?.max\n ? `.max(${parsedResponses[index].rules.max})`\n : ''\n }${brand(operationResponse)}`\n : `export const ${operationResponse} = ${inputResponse.zod}${brand(operationResponse)}`,\n ]\n : []),\n ];\n }),\n ].join('\\n\\n'),\n mutators: preprocessResponse ? [preprocessResponse] : [],\n usedRefs: useReusableSchemas ? allUsedRefs : new Set<string>(),\n };\n};\n\nexport const generateZod: ClientBuilder = async (verbOptions, options) => {\n const { implementation, mutators, usedRefs } = await generateZodRoute(\n verbOptions,\n options,\n );\n\n return {\n implementation: implementation ? `${implementation}\\n\\n` : '',\n // Zod schemas are runtime values (not type-only), so mark with values: true\n // to prevent the import writer from emitting `import type { ... }`. Sort\n // by name so import order is stable across runs.\n imports: [...usedRefs].toSorted().map((name) => ({\n name,\n schemaName: name,\n values: true,\n })),\n mutators,\n };\n};\n\nconst zodClientBuilder: ClientGeneratorsBuilder = {\n client: generateZod,\n dependencies: getZodDependencies,\n};\n\nexport const builder = () => () => zodClientBuilder;\n\nexport { isZodVersionV4 } from './compatible-v4';\n\nexport default builder;\n"],"mappings":";;;AAEA,MAAM,wBAAwB,gBAA6B;AACzD,QACE,YAAY,kBAAkB,OAC9B,YAAY,cAAc,OAC1B,YAAY,iBAAiB,OAC7B,YAAY,kBAAkB;;AAIlC,MAAa,kBAAkB,gBAA6B;CAC1D,MAAM,UAAU,qBAAqB,YAAY;AAEjD,KAAI,CAAC,QACH,QAAO;CAGT,MAAM,YAAY,QAAQ,MAAM,IAAI,CAAC;AAErC,QAAO,gBAAgB,WAAW,QAAQ;;AAG5C,MAAa,oBAAoB,YAAqB;AACpD,QAAO,UAAU,aAAa;;AAGhC,MAAa,oBAAoB,YAAqB;AACpD,QAAO,UAAU,aAAa;;AAGhC,MAAa,wBAAwB,YAAqB;AACxD,QAAO,UAAU,iBAAiB;;AAKpC,MAAa,yBACX,SACA,QACA,eACwB;AACxB,KAAI,WAAW,OACb,QAAO,CAAC,CAAC,gBAAgB,WAAW,CAAC;KAErC,QAAO,SACH,CACE,CAAC,UAAU,WAAW,EACtB,CAAC,UAAU,KAAA,EAAU,CACtB,GACD,CAAC,CAAC,UAAU,WAAW,CAAC;;AAIhC,MAAa,yBAAyB,SAAkB,WAAoB;AAC1E,QAAO,WAAW,SAAS,iBAAiB;;;;;;;;;AAU9C,MAAa,8BAA8B,YAAqB;AAC9D,QAAO,UAAU,gBAAgB;;;;ACrBnC,MAAM,mBAA0C,CAC9C;CACE,SAAS,CACP;E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AACD,WAAO,CACL,GAAI,cAAc,SAAS,CAAC,cAAc,OAAO,GAAG,EAAE,EACtD,GAAI,cAAc,MACd,CACE,gBAAgB,OAAO,UACnB,gBAAgB,kBAAkB,SAChC,cAAc,IACf;eACN,kBAAkB,eAAe,kBAAkB,OAC5C,gBAAgB,OAAO,OAAO,MAC1B,QAAQ,gBAAgB,OAAO,MAAM,IAAI,KACzC,KAEJ,gBAAgB,OAAO,OAAO,MAC1B,QAAQ,gBAAgB,OAAO,MAAM,IAAI,KACzC,KACH,MAAM,kBAAkB,KAC3B,gBAAgB,kBAAkB,KAAK,cAAc,MAAM,MAAM,kBAAkB,GACxF,GACD,EAAE,CACP;KACD;GACH,CAAC,KAAK,OAAO;EACd,UAAU,qBAAqB,CAAC,mBAAmB,GAAG,EAAE;EACxD,UAAU,qBAAqB,8BAAc,IAAI,KAAa;EAC/D;;AAGH,MAAa,cAA6B,OAAO,aAAa,YAAY;CACxE,MAAM,EAAE,gBAAgB,UAAU,aAAa,MAAM,iBACnD,aACA,QACD;AAED,QAAO;EACL,gBAAgB,iBAAiB,GAAG,eAAe,QAAQ;EAI3D,SAAS,CAAC,GAAG,SAAS,CAAC,UAAU,CAAC,KAAK,UAAU;GAC/C;GACA,YAAY;GACZ,QAAQ;GACT,EAAE;EACH;EACD;;AAGH,MAAM,mBAA4C;CAChD,QAAQ;CACR,cAAc;CACf;AAED,MAAa,sBAAsB"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/compatible-v4.ts","../src/index.ts"],"sourcesContent":["import { compareVersions, type PackageJson } from '@orval/core';\n\nconst getZodPackageVersion = (packageJson: PackageJson) => {\n return (\n packageJson.resolvedVersions?.zod ??\n packageJson.dependencies?.zod ??\n packageJson.devDependencies?.zod ??\n packageJson.peerDependencies?.zod\n );\n};\n\nexport const isZodVersionV4 = (packageJson: PackageJson) => {\n const version = getZodPackageVersion(packageJson);\n\n if (!version) {\n return false;\n }\n\n const withoutRc = version.split('-')[0];\n\n return compareVersions(withoutRc, '4.0.0');\n};\n\nexport const getZodDateFormat = (isZodV4: boolean) => {\n return isZodV4 ? 'iso.date' : 'date';\n};\n\nexport const getZodTimeFormat = (isZodV4: boolean) => {\n return isZodV4 ? 'iso.time' : 'time';\n};\n\nexport const getZodDateTimeFormat = (isZodV4: boolean) => {\n return isZodV4 ? 'iso.datetime' : 'datetime';\n};\n\ntype ParameterDefinitions = Record<string, unknown>;\ntype ParameterFunction = [string, ParameterDefinitions | undefined];\nexport const getParameterFunctions = (\n isZodV4: boolean,\n strict: boolean,\n parameters: ParameterDefinitions,\n): ParameterFunction[] => {\n if (isZodV4 && strict) {\n return [['strictObject', parameters]];\n } else {\n return strict\n ? [\n ['object', parameters],\n ['strict', undefined],\n ]\n : [['object', parameters]];\n }\n};\n\nexport const getObjectFunctionName = (isZodV4: boolean, strict: boolean) => {\n return isZodV4 && strict ? 'strictObject' : 'object';\n};\n\n/**\n * Returns the object constructor to use for open/generic objects.\n *\n * - Zod v4 supports `zod.looseObject({...})` directly.\n * - Zod v3 falls back to `zod.object({...})` and is finalized with\n * `.passthrough()` during parsing.\n */\nexport const getLooseObjectFunctionName = (isZodV4: boolean) => {\n return isZodV4 ? 'looseObject' : 'object';\n};\n","/* eslint-disable unicorn/no-array-reduce */\n\nimport {\n camel,\n type ClientBuilder,\n type ClientGeneratorsBuilder,\n type ContextSpec,\n escape,\n generateMutator,\n type GeneratorDependency,\n type GeneratorMutator,\n type GeneratorOptions,\n type GeneratorVerbOptions,\n getFormDataFieldFileType,\n getNumberWord,\n getRefInfo,\n isBoolean,\n isNumber,\n isObject,\n isString,\n jsStringEscape,\n logVerbose,\n type OpenApiParameterObject,\n type OpenApiReferenceObject,\n type OpenApiRequestBodyObject,\n type OpenApiResponseObject,\n type OpenApiSchemaObject,\n pascal,\n resolveRef,\n stringify,\n type ZodCoerceType,\n} from '@orval/core';\nimport { unique } from 'remeda';\n\nimport {\n getLooseObjectFunctionName,\n getObjectFunctionName,\n getParameterFunctions,\n getZodDateFormat,\n getZodDateTimeFormat,\n getZodTimeFormat,\n isZodVersionV4,\n} from './compatible-v4';\n\nconst ZOD_DEPENDENCIES: GeneratorDependency[] = [\n {\n exports: [\n {\n default: false,\n name: 'zod',\n syntheticDefaultImport: false,\n namespaceImport: true,\n values: true,\n },\n ],\n dependency: 'zod',\n },\n];\n\nexport const getZodDependencies = () => ZOD_DEPENDENCIES;\n\n/**\n * values that may appear in \"type\". Equals SchemaObjectType\n */\nconst possibleSchemaTypes = new Set([\n 'integer',\n 'number',\n 'string',\n 'boolean',\n 'object',\n 'strictObject',\n 'null',\n 'array',\n]);\n\nexport const predefinedZodFormats = new Set([\n 'date',\n 'time',\n 'date-time',\n 'email',\n 'uri',\n 'hostname',\n 'uuid',\n]);\n\ntype ResolvedZodType =\n | string\n | {\n multiType: string[];\n };\n\nconst resolveZodType = (schema: OpenApiSchemaObject): ResolvedZodType => {\n const schemaTypeValue = schema.type as unknown;\n\n // Handle array of types (OpenAPI 3.1+)\n if (Array.isArray(schemaTypeValue)) {\n // Filter out 'null' type as it's handled separately via nullable\n const nonNullTypes = schemaTypeValue\n .filter((t): t is string => isString(t))\n .filter((t) => t !== 'null' && possibleSchemaTypes.has(t))\n .map((t) => (t === 'integer' ? 'number' : t));\n\n // If multiple types, return a special marker for union handling\n if (nonNullTypes.length > 1) {\n return { multiType: nonNullTypes };\n }\n\n // Single type\n const type = nonNullTypes[0];\n\n // Handle prefixItems for tuples\n if (type === 'array' && 'prefixItems' in schema) {\n return 'tuple';\n }\n\n return type;\n }\n\n // Handle single type value\n const type = isString(schemaTypeValue) ? schemaTypeValue : undefined;\n\n // TODO: if \"prefixItems\" exists and type is \"array\", then generate a \"tuple\"\n if (schema.type === 'array' && 'prefixItems' in schema) {\n return 'tuple';\n }\n\n switch (type) {\n case 'integer': {\n return 'number';\n }\n default: {\n return type ?? 'unknown';\n }\n }\n};\n\n// https://github.com/colinhacks/zod#coercion-for-primitives\nconst COERCIBLE_TYPES = new Set([\n 'string',\n 'number',\n 'boolean',\n 'bigint',\n 'date',\n]);\n\nexport interface ZodValidationSchemaDefinition {\n functions: [string, unknown][];\n consts: string[];\n}\n\nconst minAndMaxTypes = new Set(['number', 'string', 'array']);\n\nconst removeReadOnlyProperties = (\n schema: OpenApiSchemaObject,\n): OpenApiSchemaObject => {\n if (schema.properties && isObject(schema.properties)) {\n const filteredProperties: Record<string, OpenApiSchemaObject> = {};\n\n for (const [key, value] of Object.entries(schema.properties)) {\n if (isObject(value) && 'readOnly' in value && value.readOnly) {\n continue;\n }\n filteredProperties[key] = value as OpenApiSchemaObject;\n }\n\n return {\n ...(schema as Record<string, unknown>),\n properties: filteredProperties,\n };\n }\n if (schema.items && isObject(schema.items) && 'properties' in schema.items) {\n return {\n ...(schema as Record<string, unknown>),\n items: removeReadOnlyProperties(schema.items as OpenApiSchemaObject),\n };\n }\n return schema;\n};\n\ninterface DateTimeOptions {\n offset?: boolean;\n local?: boolean;\n precision?: number;\n}\n\ninterface TimeOptions {\n precision?: -1 | 0 | 1 | 2 | 3;\n}\n\n/* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */\n\nconst COMPONENT_SCHEMAS_REF_PATTERN = /^#\\/components\\/schemas\\/[^/]+$/;\n\nconst isComponentSchemaRef = (ref: string): boolean =>\n COMPONENT_SCHEMAS_REF_PATTERN.test(ref);\n\nexport const generateZodValidationSchemaDefinition = (\n schema: OpenApiSchemaObject | OpenApiReferenceObject | undefined,\n context: ContextSpec,\n name: string,\n strict: boolean,\n isZodV4: boolean,\n rules?: {\n required?: boolean;\n dateTimeOptions?: DateTimeOptions;\n timeOptions?: TimeOptions;\n /**\n * Override schemas for properties at THIS level only.\n * Not passed to nested schemas. Used by form-data for file type handling.\n */\n propertyOverrides?: Record<string, ZodValidationSchemaDefinition>;\n /**\n * Internal registry to keep generated const names unique within a single\n * schema generation tree without leaking suffixes across unrelated top-level\n * schemas.\n */\n constNameRegistry?: Record<string, number>;\n /**\n * When true, plain `$ref`s into `#/components/schemas/*` emit a `namedRef`\n * placeholder instead of being inlined.\n */\n useReusableSchemas?: boolean;\n /**\n * When true (and `isZodV4`), the top-level (named component) schema emits a\n * `.meta({ id, description?, deprecated? })` instead of `.describe(...)`.\n * Set ONLY for top-level component-schema generation — recursive calls omit\n * it, so nested schemas keep `.describe()` and never get a duplicate `id`.\n */\n emitMeta?: boolean;\n },\n): ZodValidationSchemaDefinition => {\n if (!schema) return { functions: [], consts: [] };\n\n // Ref-aware path: emit a placeholder that the orchestrator will rewrite into\n // either a direct identifier or `z.lazy(() => Name)`.\n if (\n rules?.useReusableSchemas &&\n '$ref' in schema &&\n typeof schema.$ref === 'string' &&\n isComponentSchemaRef(schema.$ref)\n ) {\n const siblings = Object.keys(schema).filter((k) => k !== '$ref');\n\n const CHAINABLE_SIBLINGS = new Set(['nullable', 'default', 'description']);\n const isChainable = (k: string) => CHAINABLE_SIBLINGS.has(k);\n const allSiblingsChainable = siblings.every((k) => isChainable(k));\n\n if (allSiblingsChainable) {\n // Use the same identifier orval emits for the TS model type\n // (`pascal` + sanitize + suffix) so reusable schema exports are\n // consistent with operation wrappers and component types.\n // `namingConvention` governs file names only, not identifiers.\n const refName = getRefInfo(schema.$ref, context).name;\n const functions: [string, unknown][] = [\n ['namedRef', { name: refName, sourceRef: schema.$ref }],\n ];\n const consts: string[] = [];\n\n const refSchema = schema as OpenApiSchemaObject & {\n $ref: string;\n nullable?: boolean;\n default?: unknown;\n description?: string;\n };\n const refRequired = rules.required ?? false;\n const refHasDefault = refSchema.default !== undefined;\n\n // Match the main-path modifier ordering: nullability/optional first,\n // then default, then describe. Combining `.default()` with `.optional()`\n // is wrong in zod — `.optional()` short-circuits on `undefined` before\n // the inner default runs — so skip `.optional()` whenever a default is\n // present (matches the existing non-reusable behaviour at line ~932).\n if (!refRequired && refSchema.nullable) {\n functions.push(['nullish', undefined]);\n } else if (refSchema.nullable) {\n functions.push(['nullable', undefined]);\n } else if (!refRequired && !refHasDefault) {\n functions.push(['optional', undefined]);\n }\n\n // .default(...) — emit a const for non-primitive defaults. Use the same\n // constNameRegistry-based suffix that the rest of the generator uses so\n // multiple defaults sharing `name` don't collide on `<name>Default`.\n if (refHasDefault) {\n const registry = rules.constNameRegistry ?? {};\n const counter = isNumber(registry[name]) ? registry[name] + 1 : 0;\n registry[name] = counter;\n const suffix = counter ? pascal(getNumberWord(counter)) : '';\n const defaultVarName = `${name}Default${suffix}`;\n const defaultLiteral = stringify(refSchema.default);\n if (defaultLiteral !== undefined) {\n consts.push(`export const ${defaultVarName} = ${defaultLiteral};`);\n functions.push(['default', defaultVarName]);\n }\n }\n\n // .describe('...')\n if (typeof refSchema.description === 'string') {\n functions.push(['describe', `\"${escape(refSchema.description)}\"`]);\n }\n\n return { functions, consts };\n }\n\n // Non-chainable sibling present — fall back to inlining at this site only.\n // We reassign the local `schema` reference to the dereferenced form and let\n // the rest of the function process it normally.\n logVerbose(\n `[orval/zod] $ref ${schema.$ref} has non-chainable siblings ` +\n `[${siblings.filter((s) => !isChainable(s)).join(', ')}]; falling back to inlining.`,\n );\n schema = dereference(\n schema as OpenApiSchemaObject | OpenApiReferenceObject,\n context,\n );\n }\n\n const useReusableSchemas = rules?.useReusableSchemas ?? false;\n const consts: string[] = [];\n const constNameRegistry = rules?.constNameRegistry ?? {};\n const constsCounter = isNumber(constNameRegistry[name])\n ? constNameRegistry[name] + 1\n : 0;\n\n const constsCounterValue = constsCounter\n ? pascal(getNumberWord(constsCounter))\n : '';\n\n constNameRegistry[name] = constsCounter;\n\n const functions: [string, unknown][] = [];\n\n // Emit the schema's trailing description/metadata. On zod v4 with `emitMeta`\n // (top-level component schemas only) this is a single `.meta({ id, ... })`\n // carrying the schema name as `id` plus description/deprecated when present;\n // otherwise it falls back to the plain `.describe(...)`. Called from both\n // return points (the multi-type union exit and the main exit) so every schema\n // shape is covered. `.meta()` must be the LAST modifier in the chain — zod v4\n // turns `.meta({id}).describe(...)` into a `$ref` wrapper, whereas\n // `.describe(...).meta({id})` (and a lone `.meta`) stay flat.\n const pushDescriptionOrMeta = () => {\n // Empty-string descriptions are treated as absent — preserves the prior\n // `if (schema.description)` falsy-check semantics (which skipped both `''`\n // and `undefined`), so this change never emits a no-op `.describe('')` or\n // `description: ''` in meta.\n const description =\n typeof schema.description === 'string' && schema.description.length > 0\n ? schema.description\n : undefined;\n const deprecated =\n 'deprecated' in schema && schema.deprecated === true ? true : undefined;\n\n if (rules?.emitMeta && isZodV4) {\n const meta: Record<string, unknown> = { id: name };\n if (description !== undefined) meta.description = description;\n if (deprecated) meta.deprecated = true;\n functions.push(['meta', meta]);\n } else if (description !== undefined) {\n functions.push(['describe', `'${jsStringEscape(description)}'`]);\n }\n };\n\n const type = resolveZodType(schema);\n const required = rules?.required ?? false;\n const hasDefault = schema.default !== undefined;\n const nullable =\n // changing to ?? here changes behavior - so don't\n // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing\n ('nullable' in schema && schema.nullable) ||\n (Array.isArray(schema.type) && schema.type.includes('null'));\n const min = schema.minimum ?? schema.minLength ?? schema.minItems;\n const max = schema.maximum ?? schema.maxLength ?? schema.maxItems;\n\n // Handle exclusiveMinimum and exclusiveMaximum (OpenAPI 3.0 vs 3.1 compatibility)\n // OpenAPI 3.0: exclusiveMinimum/exclusiveMaximum are booleans indicating if minimum/maximum is exclusive\n // OpenAPI 3.1: exclusiveMinimum/exclusiveMaximum are numbers (the value itself)\n const exclusiveMinRaw =\n 'exclusiveMinimum' in schema ? schema.exclusiveMinimum : undefined;\n const exclusiveMaxRaw =\n 'exclusiveMaximum' in schema ? schema.exclusiveMaximum : undefined;\n\n // Convert boolean to number if using OpenAPI 3.0 format\n const exclusiveMin =\n isBoolean(exclusiveMinRaw) && exclusiveMinRaw ? min : exclusiveMinRaw;\n const exclusiveMax =\n isBoolean(exclusiveMaxRaw) && exclusiveMaxRaw ? max : exclusiveMaxRaw;\n\n const multipleOf = schema.multipleOf;\n const matches = schema.pattern ?? undefined;\n // Enum-based schemas are emitted as `zod.enum(...)` or literal unions, so\n // chaining scalar constraints onto the parent schema would generate invalid\n // Zod output. Arrays are handled separately via their item schema.\n const hasNonArrayEnum = !!schema.enum && type !== 'array';\n\n // Check for allOf/oneOf/anyOf BEFORE processing by type\n // This ensures these constraints work with any base type (string, number, object, etc.)\n let skipSwitchStatement = false;\n if (schema.allOf || schema.oneOf || schema.anyOf) {\n const separator = schema.allOf ? 'allOf' : schema.oneOf ? 'oneOf' : 'anyOf';\n\n const schemas = (schema.allOf ?? schema.oneOf ?? schema.anyOf) as (\n | OpenApiSchemaObject\n | OpenApiReferenceObject\n )[];\n\n // Use index-based naming to ensure uniqueness when processing multiple schemas\n // This prevents duplicate schema names when nullable refs are used\n const baseSchemas = schemas.map((schema, index) =>\n generateZodValidationSchemaDefinition(\n schema as OpenApiSchemaObject,\n context,\n `${camel(name)}${pascal(getNumberWord(index + 1))}`,\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n );\n\n // Handle allOf/oneOf/anyOf with additional properties - merge additional properties into the schema\n if ((schema.allOf || schema.oneOf || schema.anyOf) && schema.properties) {\n const additionalPropertiesSchema = {\n properties: schema.properties,\n required: schema.required,\n additionalProperties: schema.additionalProperties,\n type: schema.type,\n } as OpenApiSchemaObject;\n\n // Use index-based naming to ensure uniqueness\n const additionalIndex = baseSchemas.length + 1;\n const additionalPropertiesDefinition =\n generateZodValidationSchemaDefinition(\n additionalPropertiesSchema,\n context,\n `${camel(name)}${pascal(getNumberWord(additionalIndex))}`,\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n );\n\n // For oneOf/anyOf, use allOf to combine union with common properties\n // This generates: zod.union([...]).and(commonProperties)\n if (schema.oneOf || schema.anyOf) {\n functions.push([\n 'allOf',\n [\n { functions: [[separator, baseSchemas]], consts: [] },\n additionalPropertiesDefinition,\n ],\n ]);\n } else {\n // For allOf, just add to the list\n baseSchemas.push(additionalPropertiesDefinition);\n functions.push([separator, baseSchemas]);\n }\n } else {\n functions.push([separator, baseSchemas]);\n }\n skipSwitchStatement = true;\n }\n\n let defaultVarName: string | undefined;\n if (schema.default !== undefined) {\n defaultVarName = `${name}Default${constsCounterValue}`;\n let defaultValue: string | undefined;\n\n const isDateType =\n schema.type === 'string' &&\n (schema.format === 'date' || schema.format === 'date-time') &&\n context.output.override.useDates;\n\n if (isDateType) {\n // OpenApiSchemaObject defines default as 'any'\n defaultValue = `new Date(\"${escape(schema.default)}\")`;\n } else if (isObject(schema.default)) {\n // Narrow string literals individually with `as const` so `zod.enum([...])`\n // properties accept the emitted default (#3244). Whole-object/array\n // `as const` would make nested arrays `readonly`, which zod v4's\n // `.default()` rejects against its mutable parameter type (#3399).\n const entries = Object.entries(schema.default)\n .map(([key, value]) => {\n if (isString(value)) {\n return `${key}: \"${escape(value)}\" as const`;\n }\n\n if (Array.isArray(value)) {\n const arrayItems = value.map((item) =>\n isString(item) ? `\"${escape(item)}\" as const` : `${item}`,\n );\n return `${key}: [${arrayItems.join(', ')}]`;\n }\n\n if (\n value === null ||\n value === undefined ||\n isNumber(value) ||\n isBoolean(value)\n )\n return `${key}: ${value}`;\n })\n .join(', ');\n defaultValue = entries.length === 0 ? `{}` : `{ ${entries} }`;\n } else {\n // OpenApiSchemaObject defines default as 'any'\n const rawStringified = stringify(schema.default);\n defaultValue =\n rawStringified === undefined\n ? 'null'\n : rawStringified.replaceAll(\"'\", '`');\n\n // If the schema is an array with enum items, inject inplace to avoid issues with default values\n const isArrayWithEnumItems =\n Array.isArray(schema.default) &&\n type === 'array' &&\n schema.items &&\n 'enum' in schema.items &&\n schema.default.length > 0;\n\n if (isArrayWithEnumItems) {\n defaultVarName = defaultValue;\n defaultValue = undefined;\n }\n }\n if (defaultValue) {\n consts.push(`export const ${defaultVarName} = ${defaultValue};`);\n }\n }\n\n // Handle multi-type schemas (OpenAPI 3.1+ type arrays)\n if (isObject(type) && 'multiType' in type) {\n const types = type.multiType;\n functions.push([\n 'oneOf',\n types.map((t) =>\n generateZodValidationSchemaDefinition(\n {\n ...(schema as Record<string, unknown>),\n type: t,\n } as OpenApiSchemaObject,\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n ),\n ]);\n\n if (!required && nullable) {\n functions.push(['nullish', undefined]);\n } else if (nullable) {\n functions.push(['nullable', undefined]);\n } else if (!required) {\n functions.push(['optional', undefined]);\n }\n\n pushDescriptionOrMeta();\n\n return { functions, consts };\n }\n\n if (!skipSwitchStatement) {\n switch (type) {\n case 'tuple': {\n /**\n *\n * > 10.3.1.1. prefixItems\n * > The value of \"prefixItems\" MUST be a non-empty array of valid JSON Schemas.\n * >\n * > Validation succeeds if each element of the instance validates against the schema at the same position, if any.\n * > This keyword does not constrain the length of the array. If the array is longer than this keyword's value,\n * > this keyword validates only the prefix of matching length.\n * >\n * > This keyword produces an annotation value which is the largest index to which this keyword applied a subschema.\n * > The value MAY be a boolean true if a subschema was applied to every index of the instance, such as is produced by the \"items\" keyword.\n * > This annotation affects the behavior of \"items\" and \"unevaluatedItems\".\n * >\n * > Omitting this keyword has the same assertion behavior as an empty array.\n */\n if ('prefixItems' in schema) {\n const schema31 = schema as OpenApiSchemaObject;\n const prefixItems = Array.isArray(schema31.prefixItems)\n ? (schema31.prefixItems as (\n | OpenApiSchemaObject\n | OpenApiReferenceObject\n )[])\n : [];\n\n if (prefixItems.length > 0) {\n functions.push([\n 'tuple',\n prefixItems.map((item, idx) =>\n generateZodValidationSchemaDefinition(\n dereference(item, context),\n context,\n camel(`${name}-${idx}-item`),\n isZodV4,\n strict,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n ),\n ]);\n\n if (\n schema.items &&\n (max ?? Number.POSITIVE_INFINITY) > prefixItems.length\n ) {\n // only add zod.rest() if number of tuple elements can exceed provided prefixItems:\n functions.push([\n 'rest',\n generateZodValidationSchemaDefinition(\n schema.items as OpenApiSchemaObject | undefined,\n context,\n camel(`${name}-item`),\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n ]);\n }\n }\n }\n break;\n }\n case 'array': {\n functions.push([\n 'array',\n generateZodValidationSchemaDefinition(\n schema.items as OpenApiSchemaObject | undefined,\n context,\n camel(`${name}-item`),\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n ]);\n break;\n }\n case 'string': {\n if (schema.enum) {\n break;\n }\n\n if (\n context.output.override.useDates &&\n (schema.format === 'date' || schema.format === 'date-time')\n ) {\n functions.push(['date', undefined]);\n break;\n }\n\n if (schema.format === 'binary') {\n functions.push(['instanceof', 'File']);\n break;\n }\n\n // The @scalar/openapi-parser upgrader converts format: binary to\n // contentMediaType: application/octet-stream when upgrading\n // Swagger 2.0 / OAS 3.0 → OAS 3.1. Treat it the same as\n // format: binary so $ref-based model types generate File validation.\n if (\n schema.contentMediaType === 'application/octet-stream' &&\n !schema.contentEncoding\n ) {\n functions.push(['instanceof', 'File']);\n break;\n }\n\n if (isZodV4) {\n if (!predefinedZodFormats.has(schema.format ?? '')) {\n if ('const' in schema) {\n functions.push(['literal', `\"${schema.const}\"`]);\n } else if (schema.pattern && schema.format) {\n const isStartWithSlash = schema.pattern.startsWith('/');\n const isEndWithSlash = schema.pattern.endsWith('/');\n const regexp = `new RegExp('${jsStringEscape(\n schema.pattern.slice(\n isStartWithSlash ? 1 : 0,\n isEndWithSlash ? -1 : undefined,\n ),\n )}')`;\n consts.push(\n `export const ${name}RegExp${constsCounterValue} = ${regexp};\\n`,\n );\n functions.push([\n 'stringFormat',\n [\n `'${escape(schema.format)}'`,\n `${name}RegExp${constsCounterValue}`,\n ],\n ]);\n } else {\n functions.push([type as string, undefined]);\n }\n break;\n }\n } else {\n if ('const' in schema) {\n functions.push(['literal', `\"${schema.const}\"`]);\n } else {\n functions.push([type as string, undefined]);\n }\n }\n\n if (schema.format === 'date') {\n const formatAPI = getZodDateFormat(isZodV4);\n\n functions.push([formatAPI, undefined]);\n break;\n }\n\n if (schema.format === 'time') {\n const options = context.output.override.zod.timeOptions;\n const formatAPI = getZodTimeFormat(isZodV4);\n\n functions.push([formatAPI, JSON.stringify(options)]);\n break;\n }\n\n if (schema.format === 'date-time') {\n const options = context.output.override.zod.dateTimeOptions;\n const formatAPI = getZodDateTimeFormat(isZodV4);\n\n functions.push([formatAPI, JSON.stringify(options)]);\n break;\n }\n\n if (schema.format === 'email') {\n functions.push(['email', undefined]);\n break;\n }\n\n if (schema.format === 'uri') {\n functions.push(['url', undefined]);\n break;\n }\n\n if (schema.format === 'hostname') {\n if (isZodV4) {\n functions.push(['hostname', undefined]);\n } else {\n functions.push(['url', undefined]);\n }\n break;\n }\n\n if (schema.format === 'uuid') {\n functions.push(['uuid', undefined]);\n break;\n }\n\n break;\n }\n default: {\n const hasProperties = !!schema.properties;\n const properties = schema.properties ?? {};\n const hasDefinedProperties = Object.keys(properties).length > 0;\n const hasAdditionalPropertiesSchema =\n !!schema.additionalProperties &&\n !isBoolean(schema.additionalProperties);\n\n // A plain `type: object` without explicit properties/additionalProperties\n // represents an open dictionary-like object in OpenAPI and should not be\n // generated as a strict object.\n const shouldUseLooseObject =\n type === 'object' &&\n !hasDefinedProperties &&\n schema.additionalProperties === undefined &&\n !hasAdditionalPropertiesSchema;\n\n if (hasProperties && hasDefinedProperties) {\n const objectType = getObjectFunctionName(isZodV4, strict);\n\n functions.push([\n objectType,\n Object.keys(properties)\n .map((key) => ({\n [key]:\n rules?.propertyOverrides?.[key] ??\n generateZodValidationSchemaDefinition(\n properties[key] as OpenApiSchemaObject | undefined,\n context,\n camel(`${name}-${key}`),\n strict,\n isZodV4,\n {\n required: schema.required?.includes(key),\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n }))\n .reduce((acc, curr) => ({ ...acc, ...curr }), {}),\n ]);\n\n if (strict && !isZodV4) {\n functions.push(['strict', undefined]);\n }\n\n break;\n }\n\n if (shouldUseLooseObject) {\n const looseObjectType = getLooseObjectFunctionName(isZodV4);\n\n functions.push([looseObjectType, {}]);\n\n if (!isZodV4) {\n functions.push(['passthrough', undefined]);\n }\n\n break;\n }\n\n if (schema.additionalProperties) {\n functions.push([\n 'additionalProperties',\n generateZodValidationSchemaDefinition(\n isBoolean(schema.additionalProperties)\n ? {}\n : (schema.additionalProperties as OpenApiSchemaObject),\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n constNameRegistry,\n useReusableSchemas,\n },\n ),\n ]);\n\n break;\n }\n\n if (schema.enum) {\n break;\n }\n\n functions.push([type, undefined]);\n\n break;\n }\n }\n }\n\n if (!hasNonArrayEnum && isString(type) && minAndMaxTypes.has(type)) {\n // Handle minimum constraints: exclusiveMinimum (>.gt()) takes priority over minimum (.min())\n // Check if exclusive flag was set (boolean format in OpenAPI 3.0) or a different value (OpenAPI 3.1)\n const shouldUseExclusiveMin = exclusiveMinRaw !== undefined;\n const shouldUseExclusiveMax = exclusiveMaxRaw !== undefined;\n\n if (shouldUseExclusiveMin && exclusiveMin !== undefined) {\n consts.push(\n `export const ${name}ExclusiveMin${constsCounterValue} = ${exclusiveMin};`,\n );\n // Generate .gt() for exclusive minimum (> instead of >=)\n functions.push(['gt', `${name}ExclusiveMin${constsCounterValue}`]);\n } else if (min !== undefined) {\n if (min === 1) {\n functions.push(['min', `${min}`]);\n } else {\n consts.push(`export const ${name}Min${constsCounterValue} = ${min};`);\n functions.push(['min', `${name}Min${constsCounterValue}`]);\n }\n }\n\n // Handle maximum constraints: exclusiveMaximum (<.lt()) takes priority over maximum (.max())\n if (shouldUseExclusiveMax && exclusiveMax !== undefined) {\n consts.push(\n `export const ${name}ExclusiveMax${constsCounterValue} = ${exclusiveMax};`,\n );\n // Generate .lt() for exclusive maximum (< instead of <=)\n functions.push(['lt', `${name}ExclusiveMax${constsCounterValue}`]);\n } else if (max !== undefined) {\n consts.push(`export const ${name}Max${constsCounterValue} = ${max};`);\n functions.push(['max', `${name}Max${constsCounterValue}`]);\n }\n\n if (multipleOf !== undefined) {\n consts.push(\n `export const ${name}MultipleOf${constsCounterValue} = ${multipleOf.toString()};`,\n );\n functions.push(['multipleOf', `${name}MultipleOf${constsCounterValue}`]);\n }\n if (\n exclusiveMin !== undefined ||\n min !== undefined ||\n exclusiveMax !== undefined ||\n multipleOf !== undefined ||\n max !== undefined\n ) {\n consts.push(`\\n`);\n }\n }\n\n const stringFormatAlreadyEmitted =\n isZodV4 &&\n type === 'string' &&\n !!matches &&\n !!schema.format &&\n !predefinedZodFormats.has(schema.format ?? '');\n\n if (\n matches &&\n !hasNonArrayEnum &&\n type === 'string' &&\n !stringFormatAlreadyEmitted\n ) {\n const isStartWithSlash = matches.startsWith('/');\n const isEndWithSlash = matches.endsWith('/');\n\n const regexp = `new RegExp('${jsStringEscape(\n matches.slice(isStartWithSlash ? 1 : 0, isEndWithSlash ? -1 : undefined),\n )}')`;\n\n consts.push(\n `export const ${name}RegExp${constsCounterValue} = ${regexp};\\n`,\n );\n if (schema.format && !predefinedZodFormats.has(schema.format) && isZodV4) {\n functions.push([\n 'stringFormat',\n [`'${escape(schema.format)}'`, `${name}RegExp${constsCounterValue}`],\n ]);\n } else {\n functions.push(['regex', `${name}RegExp${constsCounterValue}`]);\n }\n }\n\n // Array item enums are handled by the nested item schema. Guard parent-array\n // enum emission to avoid generating invalid trailing `.enum(...)` chains.\n if (schema.enum && type !== 'array') {\n const uniqueEnumValues = unique(schema.enum);\n\n if (uniqueEnumValues.every((value) => isString(value))) {\n functions.push([\n 'enum',\n `[${uniqueEnumValues.map((value) => `'${escape(value)}'`).join(', ')}]`,\n ]);\n } else {\n functions.push([\n 'oneOf',\n uniqueEnumValues.map((value) => ({\n functions: [\n ['literal', isString(value) ? `'${escape(value)}'` : value],\n ],\n consts: [],\n })),\n ]);\n }\n }\n\n if (!required && nullable) {\n functions.push(['nullish', undefined]);\n } else if (nullable) {\n functions.push(['nullable', undefined]);\n } else if (!required && !hasDefault) {\n functions.push(['optional', undefined]);\n }\n\n if (hasDefault) {\n functions.push(['default', defaultVarName]);\n }\n\n pushDescriptionOrMeta();\n\n return { functions, consts: unique(consts) };\n};\n\n/**\n * Runtime shape passed to the user-supplied `override.zod.params` function for\n * every emitted validator. Exported so consumers can type their function with\n * `import type { ZodParamsContext } from 'orval'` instead of hand-writing it.\n */\nexport interface ZodParamsContext {\n /** The OpenAPI `operationId`, or `''` for shared component schemas. */\n operationId: string;\n /** `'schema'` is used for shared component schemas with no owning operation. */\n location: 'param' | 'query' | 'header' | 'body' | 'response' | 'schema';\n /** Generated schema name, e.g. `CreateUserBody`, or the component name. */\n schemaName: string;\n /** Path to the current property within the schema. Only object property names are appended. */\n fieldPath: string[];\n /** The Zod method being emitted, e.g. `'string'`, `'min'`, `'email'`. */\n validator: string;\n}\n\nexport interface ZodParamsInjection extends Pick<\n ZodParamsContext,\n 'operationId' | 'location' | 'schemaName'\n> {\n mutator: GeneratorMutator;\n}\n\nconst PARAMS_MODIFIER_VALIDATORS = new Set([\n 'optional',\n 'nullable',\n 'nullish',\n 'default',\n 'describe',\n // Nullary / degenerate validators — either no params arg accepted in zod v3\n // (e.g. .unknown(), .any(), .never(), .null(), .undefined(), .void()) or no\n // meaningful error to attach (unknown/any accept everything).\n 'unknown',\n 'any',\n 'never',\n 'null',\n 'undefined',\n 'void',\n]);\n\n// Validators whose single argument is already a params-shaped options object\n// (e.g. `z.iso.datetime({ offset, precision })`). For these, the injected\n// params must merge into the existing object rather than be appended as a\n// second argument.\nconst PARAMS_MERGE_INTO_OPTIONS_VALIDATORS = new Set([\n 'datetime',\n 'time',\n 'iso.datetime',\n 'iso.time',\n]);\n\nexport const parseZodValidationSchemaDefinition = (\n input: ZodValidationSchemaDefinition,\n context: ContextSpec,\n coerceTypes: boolean | ZodCoerceType[] = false,\n strict: boolean,\n isZodV4: boolean,\n preprocess?: GeneratorMutator,\n paramsInjection?: ZodParamsInjection,\n): { zod: string; consts: string; usedRefs: Set<string> } => {\n if (input.functions.length === 0) {\n return { zod: '', consts: '', usedRefs: new Set() };\n }\n\n let consts = '';\n const usedRefs = new Set<string>();\n\n const appendConstsChunk = (chunk: string) => {\n if (!chunk) {\n return;\n }\n\n if (\n consts.length > 0 &&\n !consts.endsWith('\\n') &&\n !chunk.startsWith('\\n')\n ) {\n consts += '\\n';\n }\n\n consts += chunk;\n };\n\n const formatFunctionArgs = (value: unknown): string => {\n if (value === undefined) return '';\n if (value === null) return 'null';\n if (isString(value)) return value;\n if (Array.isArray(value)) {\n return value.map((item) => formatFunctionArgs(item)).join(', ');\n }\n if (isObject(value)) {\n return stringify(value) ?? '';\n }\n if (isNumber(value) || isBoolean(value)) return `${value}`;\n return '';\n };\n\n const buildParamsArg = (\n fn: string,\n fieldPath: readonly string[],\n ): string | undefined => {\n if (!paramsInjection) return undefined;\n if (PARAMS_MODIFIER_VALIDATORS.has(fn)) return undefined;\n const ctx: ZodParamsContext = {\n operationId: paramsInjection.operationId,\n location: paramsInjection.location,\n schemaName: paramsInjection.schemaName,\n fieldPath: [...fieldPath],\n validator: fn,\n };\n return `${paramsInjection.mutator.name}(${JSON.stringify(ctx)})`;\n };\n\n const parseProperty = (\n property: [string, unknown],\n fieldPath: readonly string[] = [],\n ): string => {\n const [fn, args = ''] = property;\n\n if (fn === 'namedRef') {\n const refArgs = args as { name: string; sourceRef: string };\n usedRefs.add(refArgs.name);\n return `__REF_${refArgs.name}__`;\n }\n\n // `.meta({ id, description?, deprecated? })` — registry metadata for zod v4.\n // Built explicitly (rather than via stringify) so the description is\n // JS-string-escaped and the field order is stable: id, description,\n // deprecated.\n if (fn === 'meta') {\n const metaArgs = args as {\n id: string;\n description?: string;\n deprecated?: boolean;\n };\n const parts = [`id: '${jsStringEscape(metaArgs.id)}'`];\n if (metaArgs.description !== undefined) {\n parts.push(`description: '${jsStringEscape(metaArgs.description)}'`);\n }\n if (metaArgs.deprecated) {\n parts.push('deprecated: true');\n }\n return `.meta({ ${parts.join(', ')} })`;\n }\n\n // File | string for text contentMediaType/encoding (user can pass string, runtime wraps in Blob)\n if (fn === 'fileOrString') {\n return 'zod.instanceof(File).or(zod.string())';\n }\n\n if (fn === 'allOf') {\n const allOfArgs = args as ZodValidationSchemaDefinition[];\n // Check if all parts are objects and we need to merge them for strict mode\n const allAreObjects =\n strict &&\n allOfArgs.length > 0 &&\n allOfArgs.every((partSchema) => {\n if (partSchema.functions.length === 0) return false;\n const firstFn = partSchema.functions[0][0];\n // Check if first function is object or strictObject\n // For Zod v3 with strict, it will be object followed by strict\n return firstFn === 'object' || firstFn === 'strictObject';\n });\n\n if (allAreObjects) {\n // Merge all object properties into a single object\n const mergedProperties: Record<string, ZodValidationSchemaDefinition> =\n {};\n let allConsts = '';\n\n for (const partSchema of allOfArgs) {\n if (partSchema.consts.length > 0) {\n allConsts += partSchema.consts.join('\\n');\n }\n\n // Find the object function (might be first or second after strict)\n const objectFunctionIndex = partSchema.functions.findIndex(\n ([fnName]) => fnName === 'object' || fnName === 'strictObject',\n );\n\n if (objectFunctionIndex !== -1) {\n const objectArgs = partSchema.functions[objectFunctionIndex][1];\n if (isObject(objectArgs)) {\n // Merge properties (later schemas override earlier ones)\n Object.assign(\n mergedProperties,\n objectArgs as Record<string, ZodValidationSchemaDefinition>,\n );\n }\n }\n }\n\n if (allConsts.length > 0) {\n appendConstsChunk(allConsts);\n }\n\n // Generate merged object\n const objectType = getObjectFunctionName(isZodV4, strict);\n const mergedObjectString = `zod.${objectType}({\n${Object.entries(mergedProperties)\n .map(([key, schema]) => {\n const value = schema.functions\n .map((prop) => parseProperty(prop, [...fieldPath, key]))\n .join('');\n appendConstsChunk(schema.consts.join('\\n'));\n return ` \"${key}\": ${value.startsWith('.') ? 'zod' : ''}${value}`;\n })\n .join(',\\n')}\n})`;\n\n // Apply strict only once for Zod v3 (v4 uses strictObject)\n if (!isZodV4) {\n return `${mergedObjectString}.strict()`;\n }\n\n return mergedObjectString;\n }\n\n // Fallback to original .and() approach for non-object or non-strict cases\n let acc = '';\n for (const partSchema of allOfArgs) {\n const value = partSchema.functions\n .map((prop) => parseProperty(prop, fieldPath))\n .join('');\n const valueWithZod = `${value.startsWith('.') ? 'zod' : ''}${value}`;\n\n if (partSchema.consts.length > 0) {\n appendConstsChunk(partSchema.consts.join('\\n'));\n }\n\n if (acc.length === 0) {\n acc = valueWithZod;\n } else {\n acc += `.and(${valueWithZod})`;\n }\n }\n\n return acc;\n }\n if (fn === 'oneOf' || fn === 'anyOf') {\n const unionArgs = args as ZodValidationSchemaDefinition[];\n // Can't use zod.union() with a single item\n if (unionArgs.length === 1) {\n appendConstsChunk(unionArgs[0].consts.join('\\n'));\n return unionArgs[0].functions\n .map((prop: [string, unknown]) => parseProperty(prop, fieldPath))\n .join('');\n }\n\n const union = unionArgs.map(\n ({\n functions,\n consts: argConsts,\n }: {\n functions: [string, unknown][];\n consts: string[];\n }) => {\n const value = functions\n .map((prop) => parseProperty(prop, fieldPath))\n .join('');\n const valueWithZod = `${value.startsWith('.') ? 'zod' : ''}${value}`;\n // consts are missing here\n appendConstsChunk(argConsts.join('\\n'));\n return valueWithZod;\n },\n );\n\n return `.union([${union.join(',')}])`;\n }\n\n if (fn === 'additionalProperties') {\n const additionalPropertiesArgs = args as ZodValidationSchemaDefinition;\n const value = additionalPropertiesArgs.functions\n .map((prop: [string, unknown]) => parseProperty(prop, fieldPath))\n .join('');\n const valueWithZod = `${value.startsWith('.') ? 'zod' : ''}${value}`;\n if (Array.isArray(additionalPropertiesArgs.consts)) {\n appendConstsChunk(additionalPropertiesArgs.consts.join('\\n'));\n }\n return `zod.record(zod.string(), ${valueWithZod})`;\n }\n\n if (fn === 'object' || fn === 'strictObject' || fn === 'looseObject') {\n const objectArgs = args as Record<string, ZodValidationSchemaDefinition>;\n const objectType =\n fn === 'looseObject'\n ? isZodV4\n ? 'looseObject'\n : 'object'\n : getObjectFunctionName(isZodV4, strict);\n\n const parsedObject = `zod.${objectType}({\n${Object.entries(objectArgs)\n .map(([key, schema]) => {\n const value = schema.functions\n .map((prop) => parseProperty(prop, [...fieldPath, key]))\n .join('');\n appendConstsChunk(schema.consts.join('\\n'));\n return ` \"${key}\": ${value.startsWith('.') ? 'zod' : ''}${value}`;\n })\n .join(',\\n')}\n})`;\n\n if (fn === 'looseObject' && !isZodV4) {\n return `${parsedObject}.passthrough()`;\n }\n\n return parsedObject;\n }\n\n if (fn === 'passthrough') {\n return '.passthrough()';\n }\n\n if (fn === 'array') {\n const arrayArgs = args as ZodValidationSchemaDefinition;\n const value = arrayArgs.functions\n .map((prop: [string, unknown]) => parseProperty(prop, fieldPath))\n .join('');\n if (isString(arrayArgs.consts)) {\n appendConstsChunk(arrayArgs.consts);\n } else if (Array.isArray(arrayArgs.consts)) {\n appendConstsChunk(arrayArgs.consts.join('\\n'));\n }\n return `.array(${value.startsWith('.') ? 'zod' : ''}${value})`;\n }\n\n if (fn === 'strict' && !isZodV4) {\n return '.strict()';\n }\n\n if (fn === 'tuple') {\n return `zod.tuple([${(args as ZodValidationSchemaDefinition[])\n .map((x) => {\n const value = x.functions\n .map((prop) => parseProperty(prop, fieldPath))\n .join('');\n return `${value.startsWith('.') ? 'zod' : ''}${value}`;\n })\n .join(',\\n')}])`;\n }\n if (fn === 'rest') {\n return `.rest(zod${(args as ZodValidationSchemaDefinition).functions\n .map((prop) => parseProperty(prop, fieldPath))\n .join('')})`;\n }\n const shouldCoerceType =\n coerceTypes &&\n (Array.isArray(coerceTypes)\n ? coerceTypes.includes(fn as ZodCoerceType)\n : COERCIBLE_TYPES.has(fn));\n\n const formattedArgs = formatFunctionArgs(args);\n const paramsArg = buildParamsArg(fn, fieldPath);\n let combinedArgs: string;\n if (\n paramsArg &&\n formattedArgs &&\n PARAMS_MERGE_INTO_OPTIONS_VALIDATORS.has(fn)\n ) {\n combinedArgs = `{ ...${formattedArgs}, ...${paramsArg} }`;\n } else if (paramsArg) {\n combinedArgs = formattedArgs\n ? `${formattedArgs}, ${paramsArg}`\n : paramsArg;\n } else {\n combinedArgs = formattedArgs;\n }\n\n if (\n (fn !== 'date' && shouldCoerceType) ||\n (fn === 'date' && shouldCoerceType && context.output.override.useDates)\n ) {\n return `.coerce.${fn}(${combinedArgs})`;\n }\n\n return `.${fn}(${combinedArgs})`;\n };\n\n appendConstsChunk(input.consts.join('\\n'));\n\n const schema = input.functions.map((prop) => parseProperty(prop)).join('');\n const value = preprocess\n ? `.preprocess(${preprocess.name}, ${\n schema.startsWith('.') ? 'zod' : ''\n }${schema})`\n : schema;\n\n const zod = `${value.startsWith('.') ? 'zod' : ''}${value}`;\n // Some export consts includes `,` as prefix, adding replace to remove those\n if (consts.includes(',export')) {\n consts = consts.replaceAll(',export', '\\nexport');\n }\n return { zod, consts, usedRefs };\n};\n\nconst dereferenceScalar = (value: unknown, context: ContextSpec): unknown => {\n if (isObject(value)) {\n return dereference(\n value as OpenApiSchemaObject | OpenApiReferenceObject,\n context,\n );\n } else if (Array.isArray(value)) {\n return value.map((item) => dereferenceScalar(item, context));\n } else {\n return value;\n }\n};\n\n/**\n * Attempts to resolve a `$ref` to its target schema. Returns `undefined`\n * instead of throwing when the ref cannot be found (e.g. external refs\n * not yet bundled). Logs a verbose warning on failure to aid debugging.\n */\nfunction tryResolveRefSchema(\n $ref: string,\n context: ContextSpec,\n): OpenApiSchemaObject | undefined {\n try {\n return resolveRef({ $ref } as OpenApiReferenceObject, context)\n .schema as OpenApiSchemaObject;\n } catch (error) {\n logVerbose(\n `[orval/zod] Failed to resolve $ref \"${$ref}\":`,\n error instanceof Error ? error.message : error,\n );\n return;\n }\n}\n\n/**\n * Recursively inlines all `$ref` references in an OpenAPI schema tree,\n * producing a fully-resolved schema suitable for Zod code generation.\n *\n * Tracks visited `$ref` paths via `context.parents` to break circular\n * references (returning `{}` for cycles).\n */\nexport const dereference = (\n schema: OpenApiSchemaObject | OpenApiReferenceObject,\n context: ContextSpec,\n): OpenApiSchemaObject => {\n const refName = '$ref' in schema ? schema.$ref : undefined;\n if (refName && context.parents?.includes(refName)) {\n return {};\n }\n\n const childContext: ContextSpec = {\n ...context,\n ...(refName\n ? { parents: [...(context.parents ?? []), refName] }\n : undefined),\n };\n\n const resolvedSchema: OpenApiSchemaObject | undefined =\n '$ref' in schema\n ? (() => {\n const referencedSchema = tryResolveRefSchema(schema.$ref, context);\n\n if (!referencedSchema || !isObject(referencedSchema)) {\n return;\n }\n\n const siblingProperties = Object.fromEntries(\n Object.entries(schema as Record<string, unknown>).filter(\n ([key]) => key !== '$ref',\n ),\n );\n\n return {\n ...(referencedSchema as Record<string, unknown>),\n ...siblingProperties,\n } as OpenApiSchemaObject;\n })()\n : schema;\n\n if (!resolvedSchema) {\n return {};\n }\n\n const resolvedContext = childContext;\n\n return Object.entries(resolvedSchema).reduce<Record<string, unknown>>(\n (acc, [key, value]) => {\n if (key === 'properties' && isObject(value)) {\n acc[key] = Object.entries(value).reduce<\n Record<string, OpenApiSchemaObject>\n >((props, [propKey, propSchema]) => {\n props[propKey] = dereference(\n propSchema as OpenApiSchemaObject | OpenApiReferenceObject,\n resolvedContext,\n );\n return props;\n }, {});\n } else if (key === 'default' || key === 'example' || key === 'examples') {\n acc[key] = value;\n } else {\n acc[key] = dereferenceScalar(value, resolvedContext);\n }\n\n return acc;\n },\n {},\n ) as OpenApiSchemaObject;\n};\n\n/**\n * Generate zod schema for form-data request body.\n * Handles file type detection for top-level properties based on encoding.contentType\n * and contentMediaType. Mirrors type gen's resolveFormDataRootObject.\n */\nexport const generateFormDataZodSchema = (\n schema: OpenApiSchemaObject,\n context: ContextSpec,\n name: string,\n strict: boolean,\n isZodV4: boolean,\n encoding?: Record<string, { contentType?: string }>,\n useReusableSchemas?: boolean,\n): ZodValidationSchemaDefinition => {\n // Precompute file type overrides for top-level properties only\n const propertyOverrides: Record<string, ZodValidationSchemaDefinition> = {};\n\n if (schema.properties) {\n for (const key of Object.keys(schema.properties)) {\n const propSchema = schema.properties[key];\n const resolvedPropSchema = propSchema\n ? dereference(\n propSchema as OpenApiSchemaObject | OpenApiReferenceObject,\n context,\n )\n : undefined;\n\n const fileType = resolvedPropSchema\n ? getFormDataFieldFileType(\n resolvedPropSchema,\n encoding?.[key]?.contentType,\n )\n : undefined;\n\n if (fileType) {\n const isRequired = schema.required?.includes(key);\n const fileFunctions: [string, unknown][] = [\n fileType === 'binary'\n ? ['instanceof', 'File']\n : ['fileOrString', undefined],\n ];\n if (!isRequired) {\n fileFunctions.push(['optional', undefined]);\n }\n propertyOverrides[key] = { functions: fileFunctions, consts: [] };\n }\n }\n }\n\n // Delegate to generic handler with file type overrides\n return generateZodValidationSchemaDefinition(\n schema,\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n propertyOverrides:\n Object.keys(propertyOverrides).length > 0\n ? propertyOverrides\n : undefined,\n useReusableSchemas,\n },\n );\n};\n\nconst parseBodyAndResponse = ({\n data,\n context,\n name,\n strict,\n generate,\n isZodV4,\n parseType,\n useReusableSchemas,\n}: {\n data:\n | OpenApiResponseObject\n | OpenApiRequestBodyObject\n | OpenApiReferenceObject\n | undefined;\n context: ContextSpec;\n name: string;\n strict: boolean;\n generate: boolean;\n isZodV4: boolean;\n parseType: 'body' | 'response';\n useReusableSchemas?: boolean;\n}): {\n input: ZodValidationSchemaDefinition;\n isArray: boolean;\n rules?: {\n min?: number;\n max?: number;\n };\n} => {\n if (!data || !generate) {\n return {\n input: { functions: [], consts: [] },\n isArray: false,\n };\n }\n\n const resolvedRef = resolveRef(data, context).schema as\n | OpenApiResponseObject\n | OpenApiRequestBodyObject;\n\n // Only handle JSON and form-data; other content types (e.g., application/octet-stream)\n // Only handle JSON and form-data; other content types (e.g., application/octet-stream)\n // are skipped - unclear if this is correct behavior for root-level binary/text bodies.\n const contentEntries = Object.entries(resolvedRef.content ?? {});\n\n const jsonContent = contentEntries.find(\n isMediaType(\n // application/json\n // application/geo+json\n // application/ld+json\n // application/manifest+json\n // application/vnd.api+json (and other valid vendor subtypes)\n String.raw`^application\\/([^/;]+\\+)?json$`,\n ),\n );\n const formDataContent = contentEntries.find(\n isMediaType(String.raw`^multipart\\/form-data$`),\n );\n const [contentType, mediaType] = jsonContent\n ? (['application/json', jsonContent[1]] as const)\n : formDataContent\n ? (['multipart/form-data', formDataContent[1]] as const)\n : [undefined, undefined];\n\n const schema = mediaType?.schema;\n\n if (!schema) {\n return {\n input: { functions: [], consts: [] },\n isArray: false,\n };\n }\n const encoding = mediaType.encoding;\n\n const resolvedJsonSchema = dereference(schema, context);\n\n // keep the same behaviour for array\n if (resolvedJsonSchema.items) {\n const min =\n resolvedJsonSchema.minimum ??\n resolvedJsonSchema.minLength ??\n resolvedJsonSchema.minItems;\n const max =\n resolvedJsonSchema.maximum ??\n resolvedJsonSchema.maxLength ??\n resolvedJsonSchema.maxItems;\n\n // When useReusableSchemas is on, shallow-resolve one level so that $ref\n // references inside the items schema are preserved for named-ref emission.\n // E.g. Pets = array of {$ref: Pet} → we want to emit Pet (namedRef)\n // rather than inlining Pet's full schema.\n const rawItems: OpenApiSchemaObject | OpenApiReferenceObject =\n useReusableSchemas\n ? (() => {\n const shallowArraySchema = resolveRef(schema, context)\n .schema as OpenApiSchemaObject;\n return (shallowArraySchema.items ??\n resolvedJsonSchema.items) as OpenApiSchemaObject;\n })()\n : resolvedJsonSchema.items;\n\n return {\n input: generateZodValidationSchemaDefinition(\n parseType === 'body'\n ? removeReadOnlyProperties(rawItems as OpenApiSchemaObject)\n : (rawItems as OpenApiSchemaObject),\n context,\n name,\n strict,\n isZodV4,\n {\n required: true,\n useReusableSchemas,\n },\n ),\n isArray: true,\n rules: {\n ...(min === undefined ? {} : { min }),\n ...(max === undefined ? {} : { max }),\n },\n };\n }\n\n // When useReusableSchemas is on, pass the original schema (possibly a $ref)\n // directly to generateZodValidationSchemaDefinition so that component schema\n // references are emitted as named identifiers instead of being inlined.\n const effectiveSchema: OpenApiSchemaObject | OpenApiReferenceObject =\n useReusableSchemas\n ? parseType === 'body'\n ? removeReadOnlyProperties(schema as OpenApiSchemaObject)\n : schema\n : parseType === 'body'\n ? removeReadOnlyProperties(resolvedJsonSchema)\n : resolvedJsonSchema;\n\n const isFormData = contentType === 'multipart/form-data';\n\n return {\n input: isFormData\n ? generateFormDataZodSchema(\n effectiveSchema,\n context,\n name,\n strict,\n isZodV4,\n encoding,\n useReusableSchemas,\n )\n : generateZodValidationSchemaDefinition(\n effectiveSchema,\n context,\n name,\n strict,\n isZodV4,\n { required: true, useReusableSchemas },\n ),\n isArray: false,\n };\n};\n\nconst isMediaType =\n (pattern: string) =>\n ([contentType]: [string, object]): boolean =>\n new RegExp(pattern).test(contentType.split(';')[0].trim().toLowerCase());\n\nconst getSingleResponse = (\n responses:\n | Record<string, OpenApiResponseObject | OpenApiReferenceObject | undefined>\n | undefined,\n) => {\n if (!responses) {\n return;\n }\n\n return responses['200'] ?? responses['2XX'] ?? responses['2xx'];\n};\n\n/* eslint-enable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call */\n\nexport const parseParameters = ({\n data,\n context,\n operationName,\n isZodV4,\n strict,\n generate,\n useReusableSchemas,\n}: {\n data: (OpenApiParameterObject | OpenApiReferenceObject)[] | undefined;\n context: ContextSpec;\n operationName: string;\n isZodV4: boolean;\n strict: {\n param: boolean;\n query: boolean;\n header: boolean;\n body: boolean;\n response: boolean;\n };\n generate: {\n param: boolean;\n query: boolean;\n header: boolean;\n body: boolean;\n response: boolean;\n };\n useReusableSchemas?: boolean;\n}): {\n headers: ZodValidationSchemaDefinition;\n queryParams: ZodValidationSchemaDefinition;\n params: ZodValidationSchemaDefinition;\n} => {\n if (!data) {\n return {\n headers: {\n functions: [],\n consts: [],\n },\n queryParams: {\n functions: [],\n consts: [],\n },\n params: {\n functions: [],\n consts: [],\n },\n };\n }\n\n const initialDefinitionsByParameters: Record<\n 'headers' | 'queryParams' | 'params',\n Record<string, { functions: [string, unknown][]; consts: string[] }>\n > = {\n headers: {},\n queryParams: {},\n params: {},\n };\n\n const defintionsByParameters = data.reduce((acc, val) => {\n const { schema: parameter }: { schema: OpenApiParameterObject } =\n resolveRef(val, context);\n\n if (!parameter.schema) {\n return acc;\n }\n if (!parameter.in || !parameter.name) {\n return acc;\n }\n\n // When useReusableSchemas is on, preserve `$ref` schemas verbatim so the\n // generator can take the namedRef path. We only shallow-clone to attach\n // the parameter-level `description` without mutating the shared ref object.\n // When off, fall back to dereferencing for backward compatibility.\n const schemaForGen: OpenApiSchemaObject | OpenApiReferenceObject =\n useReusableSchemas\n ? parameter.description\n ? Object.assign({}, parameter.schema, {\n description: parameter.description,\n })\n : parameter.schema\n : (() => {\n const s = dereference(parameter.schema, context);\n s.description = parameter.description;\n return s;\n })();\n\n const mapStrict = {\n path: strict.param,\n query: strict.query,\n header: strict.header,\n };\n\n const mapGenerate = {\n path: generate.param,\n query: generate.query,\n header: generate.header,\n };\n\n if (\n parameter.in !== 'path' &&\n parameter.in !== 'query' &&\n parameter.in !== 'header'\n ) {\n return acc;\n }\n\n const definition = generateZodValidationSchemaDefinition(\n schemaForGen,\n context,\n camel(`${operationName}-${parameter.in}-${parameter.name}`),\n mapStrict[parameter.in],\n isZodV4,\n {\n required: parameter.required,\n useReusableSchemas,\n },\n );\n\n if (parameter.in === 'header' && mapGenerate.header) {\n return {\n ...acc,\n headers: { ...acc.headers, [parameter.name]: definition },\n };\n }\n\n if (parameter.in === 'query' && mapGenerate.query) {\n return {\n ...acc,\n queryParams: { ...acc.queryParams, [parameter.name]: definition },\n };\n }\n\n if (parameter.in === 'path' && mapGenerate.path) {\n return {\n ...acc,\n params: { ...acc.params, [parameter.name]: definition },\n };\n }\n\n return acc;\n }, initialDefinitionsByParameters);\n\n const headers: ZodValidationSchemaDefinition = {\n functions: [],\n consts: [],\n };\n\n if (Object.keys(defintionsByParameters.headers).length > 0) {\n const parameterFunctions = getParameterFunctions(\n isZodV4,\n strict.header,\n defintionsByParameters.headers,\n );\n\n headers.functions.push(...parameterFunctions);\n }\n\n const queryParams: ZodValidationSchemaDefinition = {\n functions: [],\n consts: [],\n };\n\n if (Object.keys(defintionsByParameters.queryParams).length > 0) {\n const parameterFunctions = getParameterFunctions(\n isZodV4,\n strict.query,\n defintionsByParameters.queryParams,\n );\n\n queryParams.functions.push(...parameterFunctions);\n }\n\n const params: ZodValidationSchemaDefinition = {\n functions: [],\n consts: [],\n };\n\n if (Object.keys(defintionsByParameters.params).length > 0) {\n const parameterFunctions = getParameterFunctions(\n isZodV4,\n strict.param,\n defintionsByParameters.params,\n );\n\n params.functions.push(...parameterFunctions);\n }\n\n return {\n headers,\n queryParams,\n params,\n };\n};\n\nconst generateZodRoute = async (\n { operationId, operationName, verb, override }: GeneratorVerbOptions,\n { pathRoute, context, output }: GeneratorOptions,\n) => {\n const isZodV4 =\n !!context.output.packageJson && isZodVersionV4(context.output.packageJson);\n const useReusableSchemas =\n context.output.override.zod.generateReusableSchemas;\n const spec = context.spec.paths?.[pathRoute];\n\n if (spec == undefined) {\n throw new Error(`No such path ${pathRoute} in ${context.projectName}`);\n }\n\n const parameters = [\n ...(spec.parameters ?? []),\n ...(spec[verb]?.parameters ?? []),\n ];\n\n const parsedParameters = parseParameters({\n data: parameters,\n context,\n operationName,\n isZodV4,\n strict: override.zod.strict,\n generate: override.zod.generate,\n useReusableSchemas,\n });\n\n const requestBody = spec[verb]?.requestBody;\n const parsedBody = parseBodyAndResponse({\n data: requestBody,\n context,\n name: camel(`${operationName}-body`),\n strict: override.zod.strict.body,\n generate: override.zod.generate.body,\n isZodV4,\n parseType: 'body',\n useReusableSchemas,\n });\n\n const responses = (\n context.output.override.zod.generateEachHttpStatus\n ? Object.entries(spec[verb]?.responses ?? {})\n : [['', getSingleResponse(spec[verb]?.responses)]]\n ) as [string, OpenApiResponseObject | OpenApiReferenceObject][];\n const parsedResponses = responses.map(([code, response]) =>\n parseBodyAndResponse({\n data: response,\n context,\n name: camel(`${operationName}-${code}-response`),\n strict: override.zod.strict.response,\n generate: override.zod.generate.response,\n isZodV4,\n parseType: 'response',\n useReusableSchemas,\n }),\n );\n\n const preprocessParams = override.zod.preprocess?.param\n ? await generateMutator({\n output,\n mutator: override.zod.preprocess.response,\n name: `${operationName}PreprocessParams`,\n workspace: context.workspace,\n tsconfig: context.output.tsconfig,\n })\n : undefined;\n\n const paramsMutator = override.zod.params\n ? await generateMutator({\n output,\n mutator: override.zod.params,\n name: `${operationName}ZodParams`,\n workspace: context.workspace,\n tsconfig: context.output.tsconfig,\n })\n : undefined;\n\n const pascalOperationName = pascal(operationName);\n const makeParamsInjection = (\n location: ZodParamsInjection['location'],\n schemaSuffix: string,\n ): ZodParamsInjection | undefined =>\n paramsMutator\n ? {\n mutator: paramsMutator,\n operationId,\n location,\n schemaName: `${pascalOperationName}${schemaSuffix}`,\n }\n : undefined;\n\n let inputParams = parseZodValidationSchemaDefinition(\n parsedParameters.params,\n context,\n override.zod.coerce.param,\n override.zod.strict.param,\n isZodV4,\n preprocessParams,\n makeParamsInjection('param', 'Params'),\n );\n\n const preprocessQueryParams = override.zod.preprocess?.query\n ? await generateMutator({\n output,\n mutator: override.zod.preprocess.response,\n name: `${operationName}PreprocessQueryParams`,\n workspace: context.workspace,\n tsconfig: context.output.tsconfig,\n })\n : undefined;\n\n let inputQueryParams = parseZodValidationSchemaDefinition(\n parsedParameters.queryParams,\n context,\n override.zod.coerce.query,\n override.zod.strict.query,\n isZodV4,\n preprocessQueryParams,\n makeParamsInjection('query', 'QueryParams'),\n );\n\n const preprocessHeader = override.zod.preprocess?.header\n ? await generateMutator({\n output,\n mutator: override.zod.preprocess.response,\n name: `${operationName}PreprocessHeader`,\n workspace: context.workspace,\n tsconfig: context.output.tsconfig,\n })\n : undefined;\n\n let inputHeaders = parseZodValidationSchemaDefinition(\n parsedParameters.headers,\n context,\n override.zod.coerce.header,\n override.zod.strict.header,\n isZodV4,\n preprocessHeader,\n makeParamsInjection('header', 'Header'),\n );\n\n const preprocessBody = override.zod.preprocess?.body\n ? await generateMutator({\n output,\n mutator: override.zod.preprocess.response,\n name: `${operationName}PreprocessBody`,\n workspace: context.workspace,\n tsconfig: context.output.tsconfig,\n })\n : undefined;\n\n let inputBody = parseZodValidationSchemaDefinition(\n parsedBody.input,\n context,\n override.zod.coerce.body,\n override.zod.strict.body,\n isZodV4,\n preprocessBody,\n makeParamsInjection('body', 'Body'),\n );\n\n const preprocessResponse = override.zod.preprocess?.response\n ? await generateMutator({\n output,\n mutator: override.zod.preprocess.response,\n name: `${operationName}PreprocessResponse`,\n workspace: context.workspace,\n tsconfig: context.output.tsconfig,\n })\n : undefined;\n\n const inputResponses = parsedResponses.map((parsedResponse, index) =>\n parseZodValidationSchemaDefinition(\n parsedResponse.input,\n context,\n override.zod.coerce.response,\n override.zod.strict.response,\n isZodV4,\n preprocessResponse,\n makeParamsInjection(\n 'response',\n responses[index][0] ? `${responses[index][0]}Response` : 'Response',\n ),\n ),\n );\n\n const SENTINEL_PATTERN = /__REF_([A-Za-z_$][A-Za-z0-9_$]*)__/g;\n const rewriteSentinels = (s: string): string =>\n s.replaceAll(SENTINEL_PATTERN, (_m, name: string) => name);\n\n const allUsedRefs = new Set<string>([\n ...inputParams.usedRefs,\n ...inputQueryParams.usedRefs,\n ...inputHeaders.usedRefs,\n ...inputBody.usedRefs,\n ...inputResponses.flatMap((r) => [...r.usedRefs]),\n ]);\n\n if (useReusableSchemas && allUsedRefs.size > 0) {\n inputParams = { ...inputParams, zod: rewriteSentinels(inputParams.zod) };\n inputQueryParams = {\n ...inputQueryParams,\n zod: rewriteSentinels(inputQueryParams.zod),\n };\n inputHeaders = {\n ...inputHeaders,\n zod: rewriteSentinels(inputHeaders.zod),\n };\n inputBody = { ...inputBody, zod: rewriteSentinels(inputBody.zod) };\n for (let i = 0; i < inputResponses.length; i++) {\n inputResponses[i] = {\n ...inputResponses[i],\n zod: rewriteSentinels(inputResponses[i].zod),\n };\n }\n }\n\n if (\n !inputParams.zod &&\n !inputQueryParams.zod &&\n !inputHeaders.zod &&\n !inputBody.zod &&\n !inputResponses.some((inputResponse) => inputResponse.zod)\n ) {\n return {\n implementation: '',\n mutators: [],\n usedRefs: new Set<string>(),\n };\n }\n\n const useBrandedTypes = override.zod.useBrandedTypes;\n const brand = (name: string) =>\n useBrandedTypes\n ? isZodV4\n ? `.brand(\"${name}\")`\n : `.brand<\"${name}\">()`\n : '';\n\n // With `generateReusableSchemas`, operations import component schemas by\n // their PascalCase name from a sibling schemas module. When an operation's\n // own pascalized wrapper name (e.g. `ListPetsResponse` from operationId\n // `listPets`) matches an imported ref, the generated `export const` shadows\n // the import and produces a self-referential initializer that TS rejects\n // with TS7022. Detect the collision and append `Schema` (with a counter for\n // further collisions) so the import keeps its meaning. For the array case\n // both the wrapper and its `Item` companion are checked together so they\n // stay in sync. The original name is preserved when there is no collision,\n // so non-colliding operations are unaffected.\n //\n // `localTaken` seeds from the imported refs and accumulates the names this\n // call hands out, so wrappers within the same operation (`Params`, `Body`,\n // per-status `Response`, …) can't pick a name another wrapper just claimed.\n // The fixed suffixes already keep these distinct in practice, but tracking\n // allocations removes the implicit invariant — future suffix additions stay\n // safe by construction.\n const localTaken = new Set(allUsedRefs);\n const allocateExportName = (baseName: string, hasItem: boolean): string => {\n const collides = (name: string) =>\n localTaken.has(name) || (hasItem && localTaken.has(`${name}Item`));\n const reserve = (name: string) => {\n localTaken.add(name);\n if (hasItem) localTaken.add(`${name}Item`);\n };\n if (!collides(baseName)) {\n reserve(baseName);\n return baseName;\n }\n let counter = 0;\n let candidate = `${baseName}Schema`;\n while (collides(candidate)) {\n counter += 1;\n candidate = `${baseName}Schema${counter}`;\n }\n reserve(candidate);\n return candidate;\n };\n\n const paramsName = allocateExportName(`${pascalOperationName}Params`, false);\n const queryParamsName = allocateExportName(\n `${pascalOperationName}QueryParams`,\n false,\n );\n const headerName = allocateExportName(`${pascalOperationName}Header`, false);\n const bodyName = allocateExportName(\n `${pascalOperationName}Body`,\n parsedBody.isArray,\n );\n\n return {\n implementation: [\n ...(inputParams.consts ? [inputParams.consts] : []),\n ...(inputParams.zod\n ? [\n `export const ${paramsName} = ${inputParams.zod}${brand(paramsName)}`,\n ]\n : []),\n ...(inputQueryParams.consts ? [inputQueryParams.consts] : []),\n ...(inputQueryParams.zod\n ? [\n `export const ${queryParamsName} = ${inputQueryParams.zod}${brand(queryParamsName)}`,\n ]\n : []),\n ...(inputHeaders.consts ? [inputHeaders.consts] : []),\n ...(inputHeaders.zod\n ? [\n `export const ${headerName} = ${inputHeaders.zod}${brand(headerName)}`,\n ]\n : []),\n ...(inputBody.consts ? [inputBody.consts] : []),\n ...(inputBody.zod\n ? [\n parsedBody.isArray\n ? `export const ${bodyName}Item = ${inputBody.zod}\nexport const ${bodyName} = zod.array(${bodyName}Item)${\n parsedBody.rules?.min ? `.min(${parsedBody.rules.min})` : ''\n }${\n parsedBody.rules?.max ? `.max(${parsedBody.rules.max})` : ''\n }${brand(bodyName)}`\n : `export const ${bodyName} = ${inputBody.zod}${brand(bodyName)}`,\n ]\n : []),\n ...inputResponses.flatMap((inputResponse, index) => {\n const operationResponse = allocateExportName(\n pascal(`${operationName}-${responses[index][0]}-response`),\n parsedResponses[index].isArray,\n );\n return [\n ...(inputResponse.consts ? [inputResponse.consts] : []),\n ...(inputResponse.zod\n ? [\n parsedResponses[index].isArray\n ? `export const ${operationResponse}Item = ${\n inputResponse.zod\n }\nexport const ${operationResponse} = zod.array(${operationResponse}Item)${\n parsedResponses[index].rules?.min\n ? `.min(${parsedResponses[index].rules.min})`\n : ''\n }${\n parsedResponses[index].rules?.max\n ? `.max(${parsedResponses[index].rules.max})`\n : ''\n }${brand(operationResponse)}`\n : `export const ${operationResponse} = ${inputResponse.zod}${brand(operationResponse)}`,\n ]\n : []),\n ];\n }),\n ].join('\\n\\n'),\n mutators: [\n ...(preprocessResponse ? [preprocessResponse] : []),\n // Unconditional even when this operation's parsed schemas don't\n // reference `paramsMutator.name`: in `single` mode, inline component\n // schemas (which DO reference it) rely on this entry to emit the\n // import. The cost is one harmless `import { zodParams }` line on\n // operations whose request/response have no leaf validators to inject.\n ...(paramsMutator ? [paramsMutator] : []),\n ],\n usedRefs: useReusableSchemas ? allUsedRefs : new Set<string>(),\n };\n};\n\nexport const generateZod: ClientBuilder = async (verbOptions, options) => {\n const { implementation, mutators, usedRefs } = await generateZodRoute(\n verbOptions,\n options,\n );\n\n return {\n implementation: implementation ? `${implementation}\\n\\n` : '',\n // Zod schemas are runtime values (not type-only), so mark with values: true\n // to prevent the import writer from emitting `import type { ... }`. Sort\n // by name so import order is stable across runs.\n imports: [...usedRefs].toSorted().map((name) => ({\n name,\n schemaName: name,\n values: true,\n })),\n mutators,\n };\n};\n\nconst zodClientBuilder: ClientGeneratorsBuilder = {\n client: generateZod,\n dependencies: getZodDependencies,\n};\n\nexport const builder = () => () => zodClientBuilder;\n\nexport { isZodVersionV4 } from './compatible-v4';\n\nexport default builder;\n"],"mappings":";;;AAEA,MAAM,wBAAwB,gBAA6B;AACzD,QACE,YAAY,kBAAkB,OAC9B,YAAY,cAAc,OAC1B,YAAY,iBAAiB,OAC7B,YAAY,kBAAkB;;AAIlC,MAAa,kBAAkB,gBAA6B;CAC1D,MAAM,UAAU,qBAAqB,YAAY;AAEjD,KAAI,CAAC,QACH,QAAO;CAGT,MAAM,YAAY,QAAQ,MAAM,IAAI,CAAC;AAErC,QAAO,gBAAgB,WAAW,QAAQ;;AAG5C,MAAa,oBAAoB,YAAqB;AACpD,QAAO,UAAU,aAAa;;AAGhC,MAAa,oBAAoB,YAAqB;AACpD,QAAO,UAAU,aAAa;;AAGhC,MAAa,wBAAwB,YAAqB;AACxD,QAAO,UAAU,iBAAiB;;AAKpC,MAAa,yBACX,SACA,QACA,eACwB;AACxB,KAAI,WAAW,OACb,QAAO,CAAC,CAAC,gBAAgB,WAAW,CAAC;KAErC,QAAO,SACH,CACE,CAAC,UAAU,WAAW,EACtB,CAAC,UAAU,KAAA,EAAU,CACtB,GACD,CAAC,CAAC,UAAU,WAAW,CAAC;;AAIhC,MAAa,yBAAyB,SAAkB,WAAoB;AAC1E,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AsB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orval/zod",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.14.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"nuke": "rimraf .turbo dist node_modules"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@orval/core": "8.
|
|
38
|
+
"@orval/core": "8.14.0",
|
|
39
39
|
"remeda": "^2.33.6"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|