@orval/zod 8.14.0 → 8.16.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 CHANGED
@@ -20,6 +20,15 @@ interface TimeOptions {
20
20
  }
21
21
  declare const generateZodValidationSchemaDefinition: (schema: OpenApiSchemaObject | OpenApiReferenceObject | undefined, context: ContextSpec, name: string, strict: boolean, isZodV4: boolean, rules?: {
22
22
  required?: boolean;
23
+ /**
24
+ * Required keys inherited from sibling `allOf` members. Per JSON Schema /
25
+ * OpenAPI 3.1, a `required` array in one `allOf` member applies to
26
+ * properties contributed by ANY member, so it is collected at the `allOf`
27
+ * level and applied here. Consumed at THIS object level only — never
28
+ * forwarded into nested property schemas, so a deeper object sharing a key
29
+ * name is unaffected. (#3171)
30
+ */
31
+ additionalRequired?: string[];
23
32
  dateTimeOptions?: DateTimeOptions;
24
33
  timeOptions?: TimeOptions;
25
34
  /**
@@ -72,11 +81,18 @@ declare const parseZodValidationSchemaDefinition: (input: ZodValidationSchemaDef
72
81
  usedRefs: Set<string>;
73
82
  };
74
83
  /**
75
- * Recursively inlines all `$ref` references in an OpenAPI schema tree,
76
- * producing a fully-resolved schema suitable for Zod code generation.
84
+ * Recursively inlines all `$ref` and `$dynamicRef` references in an OpenAPI
85
+ * schema tree, producing a fully-resolved schema suitable for Zod code generation.
77
86
  *
78
87
  * Tracks visited `$ref` paths via `context.parents` to break circular
79
88
  * references (returning `{}` for cycles).
89
+ *
90
+ * `$dynamicRef` is resolved using the dynamic scope attached to `context`:
91
+ * 1. Look up the anchor name in `context.dynamicScope`.
92
+ * 2. If not found, fall back to scanning `components.schemas` for a schema
93
+ * that declares `$dynamicAnchor` with the same name.
94
+ * 3. If resolved to a concrete schema, inline it (same as `$ref`).
95
+ * 4. If unresolved, external, or a generic parameter → return `{}`.
80
96
  */
81
97
  declare const dereference: (schema: OpenApiSchemaObject | OpenApiReferenceObject, context: ContextSpec) => OpenApiSchemaObject;
82
98
  /**
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { camel, compareVersions, escape, generateMutator, getFormDataFieldFileType, getNumberWord, getRefInfo, isBoolean, isNumber, isObject, isString, jsStringEscape, logVerbose, pascal, resolveRef, stringify } from "@orval/core";
1
+ import { buildDynamicScope, camel, compareVersions, escape, generateMutator, getDynamicAnchorName, getFormDataFieldFileType, getNumberWord, getRefInfo, isBoolean, isDynamicReference, isNumber, isObject, isString, jsStringEscape, jsStringLiteralEscape, logVerbose, pascal, resolveDynamicRef, resolveRef, stringify } from "@orval/core";
2
2
  import { unique } from "remeda";
3
3
  //#region src/compatible-v4.ts
4
4
  const getZodPackageVersion = (packageJson) => {
@@ -124,38 +124,40 @@ const generateZodValidationSchemaDefinition = (schema, context, name, strict, is
124
124
  functions: [],
125
125
  consts: []
126
126
  };
127
+ const CHAINABLE_SIBLINGS = new Set([
128
+ "nullable",
129
+ "default",
130
+ "description"
131
+ ]);
132
+ const isChainable = (k) => CHAINABLE_SIBLINGS.has(k);
133
+ const applyChainableSiblings = (functions, consts, siblingSchema) => {
134
+ const refRequired = rules?.required ?? false;
135
+ const refHasDefault = siblingSchema.default !== void 0;
136
+ if (!refRequired && siblingSchema.nullable) functions.push(["nullish", void 0]);
137
+ else if (siblingSchema.nullable) functions.push(["nullable", void 0]);
138
+ else if (!refRequired && !refHasDefault) functions.push(["optional", void 0]);
139
+ if (refHasDefault) {
140
+ const registry = rules?.constNameRegistry ?? {};
141
+ const counter = isNumber(registry[name]) ? registry[name] + 1 : 0;
142
+ registry[name] = counter;
143
+ const defaultVarName = `${name}Default${counter ? pascal(getNumberWord(counter)) : ""}`;
144
+ const defaultLiteral = stringify(siblingSchema.default);
145
+ if (defaultLiteral !== void 0) {
146
+ consts.push(`export const ${defaultVarName} = ${defaultLiteral};`);
147
+ functions.push(["default", defaultVarName]);
148
+ }
149
+ }
150
+ if (typeof siblingSchema.description === "string") functions.push(["describe", `'${jsStringEscape(siblingSchema.description)}'`]);
151
+ };
127
152
  if (rules?.useReusableSchemas && "$ref" in schema && typeof schema.$ref === "string" && isComponentSchemaRef(schema.$ref)) {
128
153
  const siblings = Object.keys(schema).filter((k) => k !== "$ref");
129
- const CHAINABLE_SIBLINGS = new Set([
130
- "nullable",
131
- "default",
132
- "description"
133
- ]);
134
- const isChainable = (k) => CHAINABLE_SIBLINGS.has(k);
135
154
  if (siblings.every((k) => isChainable(k))) {
136
155
  const functions = [["namedRef", {
137
156
  name: getRefInfo(schema.$ref, context).name,
138
157
  sourceRef: schema.$ref
139
158
  }]];
140
159
  const consts = [];
141
- const refSchema = schema;
142
- const refRequired = rules.required ?? false;
143
- const refHasDefault = refSchema.default !== void 0;
144
- if (!refRequired && refSchema.nullable) functions.push(["nullish", void 0]);
145
- else if (refSchema.nullable) functions.push(["nullable", void 0]);
146
- else if (!refRequired && !refHasDefault) functions.push(["optional", void 0]);
147
- if (refHasDefault) {
148
- const registry = rules.constNameRegistry ?? {};
149
- const counter = isNumber(registry[name]) ? registry[name] + 1 : 0;
150
- registry[name] = counter;
151
- const defaultVarName = `${name}Default${counter ? pascal(getNumberWord(counter)) : ""}`;
152
- const defaultLiteral = stringify(refSchema.default);
153
- if (defaultLiteral !== void 0) {
154
- consts.push(`export const ${defaultVarName} = ${defaultLiteral};`);
155
- functions.push(["default", defaultVarName]);
156
- }
157
- }
158
- if (typeof refSchema.description === "string") functions.push(["describe", `"${escape(refSchema.description)}"`]);
160
+ applyChainableSiblings(functions, consts, schema);
159
161
  return {
160
162
  functions,
161
163
  consts
@@ -164,6 +166,29 @@ const generateZodValidationSchemaDefinition = (schema, context, name, strict, is
164
166
  logVerbose(`[orval/zod] $ref ${schema.$ref} has non-chainable siblings [${siblings.filter((s) => !isChainable(s)).join(", ")}]; falling back to inlining.`);
165
167
  schema = dereference(schema, context);
166
168
  }
169
+ if (rules?.useReusableSchemas && isDynamicReference(schema)) {
170
+ const anchorName = getDynamicAnchorName(schema.$dynamicRef);
171
+ if (anchorName) {
172
+ const { resolvedTypeName, schemaName } = resolveDynamicRef(anchorName, context);
173
+ if (resolvedTypeName !== "unknown" && schemaName) {
174
+ const siblings = Object.keys(schema).filter((k) => k !== "$dynamicRef");
175
+ if (siblings.every((k) => isChainable(k))) {
176
+ const functions = [["namedRef", {
177
+ name: resolvedTypeName,
178
+ sourceRef: `${COMPONENT_SCHEMAS_PREFIX}${encodeSegment(schemaName)}`
179
+ }]];
180
+ const consts = [];
181
+ applyChainableSiblings(functions, consts, schema);
182
+ return {
183
+ functions,
184
+ consts
185
+ };
186
+ }
187
+ logVerbose(`[orval/zod] $dynamicRef ${schema.$dynamicRef} has non-chainable siblings [${siblings.filter((s) => !isChainable(s)).join(", ")}]; falling back to inlining.`);
188
+ }
189
+ }
190
+ schema = dereference(schema, context);
191
+ }
167
192
  const useReusableSchemas = rules?.useReusableSchemas ?? false;
168
193
  const consts = [];
169
194
  const constNameRegistry = rules?.constNameRegistry ?? {};
@@ -197,8 +222,14 @@ const generateZodValidationSchemaDefinition = (schema, context, name, strict, is
197
222
  let skipSwitchStatement = false;
198
223
  if (schema.allOf || schema.oneOf || schema.anyOf) {
199
224
  const separator = schema.allOf ? "allOf" : schema.oneOf ? "oneOf" : "anyOf";
200
- const baseSchemas = (schema.allOf ?? schema.oneOf ?? schema.anyOf).map((schema, index) => generateZodValidationSchemaDefinition(schema, context, `${camel(name)}${pascal(getNumberWord(index + 1))}`, strict, isZodV4, {
225
+ const schemas = schema.allOf ?? schema.oneOf ?? schema.anyOf;
226
+ const allOfRequired = schema.allOf ? [...new Set([...schema.required ?? [], ...schemas.flatMap((member) => {
227
+ const memberRequired = ("$ref" in member && typeof member.$ref === "string" ? tryResolveRefSchema(member.$ref, context) : member)?.required;
228
+ return Array.isArray(memberRequired) ? memberRequired : [];
229
+ })])] : void 0;
230
+ const baseSchemas = schemas.map((schema, index) => generateZodValidationSchemaDefinition(schema, context, `${camel(name)}${pascal(getNumberWord(index + 1))}`, strict, isZodV4, {
201
231
  required: true,
232
+ additionalRequired: allOfRequired,
202
233
  constNameRegistry,
203
234
  useReusableSchemas
204
235
  }));
@@ -212,6 +243,7 @@ const generateZodValidationSchemaDefinition = (schema, context, name, strict, is
212
243
  const additionalIndex = baseSchemas.length + 1;
213
244
  const additionalPropertiesDefinition = generateZodValidationSchemaDefinition(additionalPropertiesSchema, context, `${camel(name)}${pascal(getNumberWord(additionalIndex))}`, strict, isZodV4, {
214
245
  required: true,
246
+ additionalRequired: allOfRequired,
215
247
  constNameRegistry,
216
248
  useReusableSchemas
217
249
  });
@@ -328,7 +360,7 @@ const generateZodValidationSchemaDefinition = (schema, context, name, strict, is
328
360
  else if (schema.pattern && schema.format) {
329
361
  const isStartWithSlash = schema.pattern.startsWith("/");
330
362
  const isEndWithSlash = schema.pattern.endsWith("/");
331
- const regexp = `new RegExp('${jsStringEscape(schema.pattern.slice(isStartWithSlash ? 1 : 0, isEndWithSlash ? -1 : void 0))}')`;
363
+ const regexp = `new RegExp('${jsStringLiteralEscape(schema.pattern.slice(isStartWithSlash ? 1 : 0, isEndWithSlash ? -1 : void 0))}')`;
332
364
  consts.push(`export const ${name}RegExp${constsCounterValue} = ${regexp};\n`);
333
365
  functions.push(["stringFormat", [`'${escape(schema.format)}'`, `${name}RegExp${constsCounterValue}`]]);
334
366
  } else functions.push([type, void 0]);
@@ -379,8 +411,9 @@ const generateZodValidationSchemaDefinition = (schema, context, name, strict, is
379
411
  const shouldUseLooseObject = type === "object" && !hasDefinedProperties && schema.additionalProperties === void 0 && !hasAdditionalPropertiesSchema;
380
412
  if (hasProperties && hasDefinedProperties) {
381
413
  const objectType = getObjectFunctionName(isZodV4, strict);
414
+ const requiredKeys = new Set([...schema.required ?? [], ...rules?.additionalRequired ?? []]);
382
415
  functions.push([objectType, Object.keys(properties).map((key) => ({ [key]: rules?.propertyOverrides?.[key] ?? generateZodValidationSchemaDefinition(properties[key], context, camel(`${name}-${key}`), strict, isZodV4, {
383
- required: schema.required?.includes(key),
416
+ required: requiredKeys.has(key),
384
417
  constNameRegistry,
385
418
  useReusableSchemas
386
419
  }) })).reduce((acc, curr) => ({
@@ -437,7 +470,7 @@ const generateZodValidationSchemaDefinition = (schema, context, name, strict, is
437
470
  if (matches && !hasNonArrayEnum && type === "string" && !stringFormatAlreadyEmitted) {
438
471
  const isStartWithSlash = matches.startsWith("/");
439
472
  const isEndWithSlash = matches.endsWith("/");
440
- const regexp = `new RegExp('${jsStringEscape(matches.slice(isStartWithSlash ? 1 : 0, isEndWithSlash ? -1 : void 0))}')`;
473
+ const regexp = `new RegExp('${jsStringLiteralEscape(matches.slice(isStartWithSlash ? 1 : 0, isEndWithSlash ? -1 : void 0))}')`;
441
474
  consts.push(`export const ${name}RegExp${constsCounterValue} = ${regexp};\n`);
442
475
  if (schema.format && !predefinedZodFormats.has(schema.format) && isZodV4) functions.push(["stringFormat", [`'${escape(schema.format)}'`, `${name}RegExp${constsCounterValue}`]]);
443
476
  else functions.push(["regex", `${name}RegExp${constsCounterValue}`]);
@@ -651,16 +684,30 @@ function tryResolveRefSchema($ref, context) {
651
684
  return;
652
685
  }
653
686
  }
687
+ const COMPONENT_SCHEMAS_PREFIX = "#/components/schemas/";
688
+ function extractSchemaNameFromRef($ref) {
689
+ if (!$ref.startsWith(COMPONENT_SCHEMAS_PREFIX)) return void 0;
690
+ const raw = $ref.slice(21);
691
+ return decodeURIComponent(raw.replaceAll("~1", "/").replaceAll("~0", "~"));
692
+ }
654
693
  /**
655
- * Recursively inlines all `$ref` references in an OpenAPI schema tree,
656
- * producing a fully-resolved schema suitable for Zod code generation.
694
+ * Recursively inlines all `$ref` and `$dynamicRef` references in an OpenAPI
695
+ * schema tree, producing a fully-resolved schema suitable for Zod code generation.
657
696
  *
658
697
  * Tracks visited `$ref` paths via `context.parents` to break circular
659
698
  * references (returning `{}` for cycles).
699
+ *
700
+ * `$dynamicRef` is resolved using the dynamic scope attached to `context`:
701
+ * 1. Look up the anchor name in `context.dynamicScope`.
702
+ * 2. If not found, fall back to scanning `components.schemas` for a schema
703
+ * that declares `$dynamicAnchor` with the same name.
704
+ * 3. If resolved to a concrete schema, inline it (same as `$ref`).
705
+ * 4. If unresolved, external, or a generic parameter → return `{}`.
660
706
  */
661
707
  const dereference = (schema, context) => {
662
708
  const refName = "$ref" in schema ? schema.$ref : void 0;
663
709
  if (refName && context.parents?.includes(refName)) return {};
710
+ if (isDynamicReference(schema)) return dereferenceDynamicRef(schema, context);
664
711
  const childContext = {
665
712
  ...context,
666
713
  ...refName ? { parents: [...context.parents ?? [], refName] } : void 0
@@ -675,17 +722,56 @@ const dereference = (schema, context) => {
675
722
  };
676
723
  })() : schema;
677
724
  if (!resolvedSchema) return {};
678
- const resolvedContext = childContext;
679
- return Object.entries(resolvedSchema).reduce((acc, [key, value]) => {
725
+ const resolvedContext = buildScopedContext(childContext, refName, resolvedSchema);
726
+ if (isDynamicReference(resolvedSchema)) return dereferenceDynamicRef(resolvedSchema, resolvedContext);
727
+ return dereferenceProperties(resolvedSchema, resolvedContext);
728
+ };
729
+ function dereferenceProperties(schema, context) {
730
+ return Object.entries(schema).reduce((acc, [key, value]) => {
680
731
  if (key === "properties" && isObject(value)) acc[key] = Object.entries(value).reduce((props, [propKey, propSchema]) => {
681
- props[propKey] = dereference(propSchema, resolvedContext);
732
+ props[propKey] = dereference(propSchema, context);
682
733
  return props;
683
734
  }, {});
684
735
  else if (key === "default" || key === "example" || key === "examples") acc[key] = value;
685
- else acc[key] = dereferenceScalar(value, resolvedContext);
736
+ else acc[key] = dereferenceScalar(value, context);
686
737
  return acc;
687
738
  }, {});
688
- };
739
+ }
740
+ function buildScopedContext(childContext, refName, resolvedSchema) {
741
+ if (!refName) return childContext;
742
+ const schemaName = extractSchemaNameFromRef(refName);
743
+ if (!schemaName) return childContext;
744
+ const schemaRecord = resolvedSchema;
745
+ const hasDynamicAnchor = typeof schemaRecord.$dynamicAnchor === "string";
746
+ const defs = schemaRecord.$defs;
747
+ const hasDefsAnchors = defs && typeof defs === "object" && Object.values(defs).some((d) => d && typeof d === "object" && "$dynamicAnchor" in d);
748
+ if (!hasDynamicAnchor && !hasDefsAnchors) return childContext;
749
+ return {
750
+ ...childContext,
751
+ dynamicScope: buildDynamicScope(schemaName, resolvedSchema, childContext)
752
+ };
753
+ }
754
+ function dereferenceDynamicRef(schema, context) {
755
+ const dynamicRef = schema.$dynamicRef;
756
+ const anchorName = getDynamicAnchorName(dynamicRef);
757
+ if (!anchorName) return {};
758
+ const { resolvedTypeName, schema: resolvedSchema, schemaName } = resolveDynamicRef(anchorName, context);
759
+ const dynamicRefPath = `$dynamicRef:${dynamicRef}@${schemaName ?? "?"}`;
760
+ if (context.parents?.includes(dynamicRefPath)) return {};
761
+ if (resolvedTypeName === "unknown" || !isObject(resolvedSchema)) return {};
762
+ const scopedContext = buildScopedContext({
763
+ ...context,
764
+ parents: [...context.parents ?? [], dynamicRefPath]
765
+ }, schemaName ? `${COMPONENT_SCHEMAS_PREFIX}${encodeSegment(schemaName)}` : void 0, resolvedSchema);
766
+ const siblingProperties = Object.fromEntries(Object.entries(schema).filter(([key]) => key !== "$dynamicRef"));
767
+ return dereferenceProperties({
768
+ ...resolvedSchema,
769
+ ...siblingProperties
770
+ }, scopedContext);
771
+ }
772
+ function encodeSegment(segment) {
773
+ return segment.replaceAll("~", "~0").replaceAll("/", "~1");
774
+ }
689
775
  /**
690
776
  * Generate zod schema for form-data request body.
691
777
  * Handles file type detection for top-level properties based on encoding.contentType
@@ -727,19 +813,32 @@ const parseBodyAndResponse = ({ data, context, name, strict, generate, isZodV4,
727
813
  const formDataContent = contentEntries.find(isMediaType(String.raw`^multipart\/form-data$`));
728
814
  const [contentType, mediaType] = jsonContent ? ["application/json", jsonContent[1]] : formDataContent ? ["multipart/form-data", formDataContent[1]] : [void 0, void 0];
729
815
  const schema = mediaType?.schema;
730
- if (!schema) return {
731
- input: {
732
- functions: [],
733
- consts: []
734
- },
735
- isArray: false
736
- };
816
+ if (!schema) {
817
+ if (parseType === "response") {
818
+ if (contentEntries.find(isMediaType(String.raw`^text\/plain$`))) return {
819
+ input: {
820
+ functions: [["string", void 0]],
821
+ consts: []
822
+ },
823
+ isArray: false
824
+ };
825
+ }
826
+ return {
827
+ input: {
828
+ functions: [],
829
+ consts: []
830
+ },
831
+ isArray: false
832
+ };
833
+ }
737
834
  const encoding = mediaType.encoding;
738
835
  const resolvedJsonSchema = dereference(schema, context);
739
836
  if (resolvedJsonSchema.items) {
740
837
  const min = resolvedJsonSchema.minimum ?? resolvedJsonSchema.minLength ?? resolvedJsonSchema.minItems;
741
838
  const max = resolvedJsonSchema.maximum ?? resolvedJsonSchema.maxLength ?? resolvedJsonSchema.maxItems;
742
- const rawItems = useReusableSchemas ? resolveRef(schema, context).schema.items ?? resolvedJsonSchema.items : resolvedJsonSchema.items;
839
+ const rawItems = useReusableSchemas ? (() => {
840
+ return resolveRef(schema, context).schema.items ?? resolvedJsonSchema.items;
841
+ })() : resolvedJsonSchema.items;
743
842
  return {
744
843
  input: generateZodValidationSchemaDefinition(parseType === "body" ? removeReadOnlyProperties(rawItems) : rawItems, context, name, strict, isZodV4, {
745
844
  required: true,
@@ -764,7 +863,8 @@ const parseBodyAndResponse = ({ data, context, name, strict, generate, isZodV4,
764
863
  const isMediaType = (pattern) => ([contentType]) => new RegExp(pattern).test(contentType.split(";")[0].trim().toLowerCase());
765
864
  const getSingleResponse = (responses) => {
766
865
  if (!responses) return;
767
- return responses["200"] ?? responses["2XX"] ?? responses["2xx"];
866
+ const otherSuccess = Object.entries(responses).find(([code]) => code.startsWith("2") && code !== "204" && code !== "205")?.[1];
867
+ return responses["200"] ?? responses["2XX"] ?? responses["2xx"] ?? otherSuccess ?? responses["204"] ?? responses["205"];
768
868
  };
769
869
  const parseParameters = ({ data, context, operationName, isZodV4, strict, generate, useReusableSchemas }) => {
770
870
  if (!data) return {
@@ -900,7 +1000,7 @@ const generateZodRoute = async ({ operationId, operationName, verb, override },
900
1000
  }));
901
1001
  const preprocessParams = override.zod.preprocess?.param ? await generateMutator({
902
1002
  output,
903
- mutator: override.zod.preprocess.response,
1003
+ mutator: override.zod.preprocess.param,
904
1004
  name: `${operationName}PreprocessParams`,
905
1005
  workspace: context.workspace,
906
1006
  tsconfig: context.output.tsconfig
@@ -922,7 +1022,7 @@ const generateZodRoute = async ({ operationId, operationName, verb, override },
922
1022
  let inputParams = parseZodValidationSchemaDefinition(parsedParameters.params, context, override.zod.coerce.param, override.zod.strict.param, isZodV4, preprocessParams, makeParamsInjection("param", "Params"));
923
1023
  const preprocessQueryParams = override.zod.preprocess?.query ? await generateMutator({
924
1024
  output,
925
- mutator: override.zod.preprocess.response,
1025
+ mutator: override.zod.preprocess.query,
926
1026
  name: `${operationName}PreprocessQueryParams`,
927
1027
  workspace: context.workspace,
928
1028
  tsconfig: context.output.tsconfig
@@ -930,7 +1030,7 @@ const generateZodRoute = async ({ operationId, operationName, verb, override },
930
1030
  let inputQueryParams = parseZodValidationSchemaDefinition(parsedParameters.queryParams, context, override.zod.coerce.query, override.zod.strict.query, isZodV4, preprocessQueryParams, makeParamsInjection("query", "QueryParams"));
931
1031
  const preprocessHeader = override.zod.preprocess?.header ? await generateMutator({
932
1032
  output,
933
- mutator: override.zod.preprocess.response,
1033
+ mutator: override.zod.preprocess.header,
934
1034
  name: `${operationName}PreprocessHeader`,
935
1035
  workspace: context.workspace,
936
1036
  tsconfig: context.output.tsconfig
@@ -938,7 +1038,7 @@ const generateZodRoute = async ({ operationId, operationName, verb, override },
938
1038
  let inputHeaders = parseZodValidationSchemaDefinition(parsedParameters.headers, context, override.zod.coerce.header, override.zod.strict.header, isZodV4, preprocessHeader, makeParamsInjection("header", "Header"));
939
1039
  const preprocessBody = override.zod.preprocess?.body ? await generateMutator({
940
1040
  output,
941
- mutator: override.zod.preprocess.response,
1041
+ mutator: override.zod.preprocess.body,
942
1042
  name: `${operationName}PreprocessBody`,
943
1043
  workspace: context.workspace,
944
1044
  tsconfig: context.output.tsconfig
@@ -983,7 +1083,7 @@ const generateZodRoute = async ({ operationId, operationName, verb, override },
983
1083
  zod: rewriteSentinels(inputResponses[i].zod)
984
1084
  };
985
1085
  }
986
- if (!inputParams.zod && !inputQueryParams.zod && !inputHeaders.zod && !inputBody.zod && !inputResponses.some((inputResponse) => inputResponse.zod)) return {
1086
+ if (!inputParams.zod && !inputQueryParams.zod && !inputHeaders.zod && !inputBody.zod && responses.length === 0) return {
987
1087
  implementation: "",
988
1088
  mutators: [],
989
1089
  usedRefs: /* @__PURE__ */ new Set()
@@ -1027,11 +1127,31 @@ const generateZodRoute = async ({ operationId, operationName, verb, override },
1027
1127
  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)}`] : [],
1028
1128
  ...inputResponses.flatMap((inputResponse, index) => {
1029
1129
  const operationResponse = allocateExportName(pascal(`${operationName}-${responses[index][0]}-response`), parsedResponses[index].isArray);
1030
- return [...inputResponse.consts ? [inputResponse.consts] : [], ...inputResponse.zod ? [parsedResponses[index].isArray ? `export const ${operationResponse}Item = ${inputResponse.zod}
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)}`] : []];
1130
+ if (!inputResponse.zod) {
1131
+ if (!override.zod.generate.response) return [];
1132
+ const noContentStatusCodes = new Set(["204", "205"]);
1133
+ const statusCode = responses[index][0];
1134
+ const isEachHttpStatusMode = !!statusCode;
1135
+ let isNoContent;
1136
+ if (isEachHttpStatusMode) isNoContent = noContentStatusCodes.has(statusCode);
1137
+ else {
1138
+ const specResponseKeys = new Set(Object.keys(spec[verb]?.responses ?? {}));
1139
+ isNoContent = !(specResponseKeys.has("200") || specResponseKeys.has("2XX") || specResponseKeys.has("2xx"));
1140
+ }
1141
+ return [`export const ${operationResponse} = ${isNoContent ? "zod.void()" : "zod.unknown()"}${brand(operationResponse)}`];
1142
+ }
1143
+ return [...inputResponse.consts ? [inputResponse.consts] : [], parsedResponses[index].isArray ? `export const ${operationResponse}Item = ${inputResponse.zod}
1144
+ 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)}`];
1032
1145
  })
1033
1146
  ].join("\n\n"),
1034
- mutators: [...preprocessResponse ? [preprocessResponse] : [], ...paramsMutator ? [paramsMutator] : []],
1147
+ mutators: [
1148
+ ...preprocessParams && inputParams.zod ? [preprocessParams] : [],
1149
+ ...preprocessQueryParams && inputQueryParams.zod ? [preprocessQueryParams] : [],
1150
+ ...preprocessHeader && inputHeaders.zod ? [preprocessHeader] : [],
1151
+ ...preprocessBody && inputBody.zod ? [preprocessBody] : [],
1152
+ ...preprocessResponse ? [preprocessResponse] : [],
1153
+ ...paramsMutator ? [paramsMutator] : []
1154
+ ],
1035
1155
  usedRefs: useReusableSchemas ? allUsedRefs : /* @__PURE__ */ new Set()
1036
1156
  };
1037
1157
  };
@@ -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 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,QAAO,WAAW,SAAS,i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"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 buildDynamicScope,\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 getDynamicAnchorName,\n getFormDataFieldFileType,\n getNumberWord,\n getRefInfo,\n isBoolean,\n isDynamicReference,\n isNumber,\n isObject,\n isString,\n jsStringEscape,\n jsStringLiteralEscape,\n logVerbose,\n type OpenApiParameterObject,\n type OpenApiReferenceObject,\n type OpenApiRequestBodyObject,\n type OpenApiResponseObject,\n type OpenApiSchemaObject,\n pascal,\n resolveDynamicRef,\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 /**\n * Required keys inherited from sibling `allOf` members. Per JSON Schema /\n * OpenAPI 3.1, a `required` array in one `allOf` member applies to\n * properties contributed by ANY member, so it is collected at the `allOf`\n * level and applied here. Consumed at THIS object level only — never\n * forwarded into nested property schemas, so a deeper object sharing a key\n * name is unaffected. (#3171)\n */\n additionalRequired?: string[];\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 const CHAINABLE_SIBLINGS = new Set(['nullable', 'default', 'description']);\n const isChainable = (k: string) => CHAINABLE_SIBLINGS.has(k);\n\n const applyChainableSiblings = (\n functions: [string, unknown][],\n consts: string[],\n siblingSchema: OpenApiSchemaObject & {\n nullable?: boolean;\n default?: unknown;\n description?: string;\n },\n ): void => {\n const refRequired = rules?.required ?? false;\n const refHasDefault = siblingSchema.default !== undefined;\n\n if (!refRequired && siblingSchema.nullable) {\n functions.push(['nullish', undefined]);\n } else if (siblingSchema.nullable) {\n functions.push(['nullable', undefined]);\n } else if (!refRequired && !refHasDefault) {\n functions.push(['optional', undefined]);\n }\n\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(siblingSchema.default);\n if (defaultLiteral !== undefined) {\n consts.push(`export const ${defaultVarName} = ${defaultLiteral};`);\n functions.push(['default', defaultVarName]);\n }\n }\n\n if (typeof siblingSchema.description === 'string') {\n // Use the same single-quoted, fully JS-escaped form as the primitive\n // description path (see `pushDescriptionOrMeta`). `escape` only escapes\n // quote chars, so a multi-line description would emit raw newlines and\n // break the generated string literal (TS1002).\n functions.push([\n 'describe',\n `'${jsStringEscape(siblingSchema.description)}'`,\n ]);\n }\n };\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 const allSiblingsChainable = siblings.every((k) => isChainable(k));\n\n if (allSiblingsChainable) {\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 applyChainableSiblings(\n functions,\n consts,\n schema as OpenApiSchemaObject & {\n $ref: string;\n nullable?: boolean;\n default?: unknown;\n description?: string;\n },\n );\n\n return { functions, consts };\n }\n\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 // Dynamic-ref-aware path: when useReusableSchemas is true, resolve the\n // anchor and emit a namedRef sentinel if the target is a concrete component\n // schema. The SCC pipeline then decides direct vs zod.lazy().\n if (rules?.useReusableSchemas && isDynamicReference(schema)) {\n const anchorName = getDynamicAnchorName(schema.$dynamicRef);\n if (anchorName) {\n const { resolvedTypeName, schemaName } = resolveDynamicRef(\n anchorName,\n context,\n );\n\n if (resolvedTypeName !== 'unknown' && schemaName) {\n const siblings = Object.keys(schema).filter((k) => k !== '$dynamicRef');\n const allSiblingsChainable = siblings.every((k) => isChainable(k));\n\n if (allSiblingsChainable) {\n const sourceRef = `${COMPONENT_SCHEMAS_PREFIX}${encodeSegment(schemaName)}`;\n const functions: [string, unknown][] = [\n ['namedRef', { name: resolvedTypeName, sourceRef }],\n ];\n const consts: string[] = [];\n\n applyChainableSiblings(\n functions,\n consts,\n schema as OpenApiSchemaObject & {\n $dynamicRef: string;\n nullable?: boolean;\n default?: unknown;\n description?: string;\n },\n );\n\n return { functions, consts };\n }\n\n logVerbose(\n `[orval/zod] $dynamicRef ${schema.$dynamicRef} has non-chainable siblings ` +\n `[${siblings.filter((s) => !isChainable(s)).join(', ')}]; falling back to inlining.`,\n );\n }\n }\n\n // Not emitted as namedRef (non-chainable siblings, unresolvable anchor,\n // or external ref) — dereference now so the main body sees a resolved\n // schema with a proper type instead of the raw $dynamicRef (which\n // resolveZodType classifies as 'unknown').\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 // In JSON Schema / OpenAPI 3.1 a `required` array in any `allOf` member\n // (and on the composing schema itself) applies to properties contributed by\n // any member. Collect them all so each member's own properties can be marked\n // required even when the `required` lives in a sibling member — e.g. props\n // in a `$ref` base + `required` in a constraint-only sibling. Only valid for\n // `allOf` (a conjunction); `oneOf`/`anyOf` are alternatives. (#3171)\n const allOfRequired = schema.allOf\n ? [\n ...new Set([\n ...(schema.required ?? []),\n ...schemas.flatMap((member) => {\n // Only the member's top-level `required` is needed. For `$ref`\n // members resolve shallowly (no deep property dereference) and\n // tolerate unresolvable refs — they simply contribute no keys.\n const resolved =\n '$ref' in member && typeof member.$ref === 'string'\n ? tryResolveRefSchema(member.$ref, context)\n : (member as OpenApiSchemaObject);\n const memberRequired = resolved?.required;\n return Array.isArray(memberRequired)\n ? (memberRequired as string[])\n : [];\n }),\n ]),\n ]\n : undefined;\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 additionalRequired: allOfRequired,\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 additionalRequired: allOfRequired,\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('${jsStringLiteralEscape(\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 // A property is required when this schema requires it OR when a\n // sibling `allOf` member requires it (propagated via additionalRequired). (#3171)\n const requiredKeys = new Set<string>([\n ...(schema.required ?? []),\n ...(rules?.additionalRequired ?? []),\n ]);\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: requiredKeys.has(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('${jsStringLiteralEscape(\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\nconst COMPONENT_SCHEMAS_PREFIX = '#/components/schemas/';\n\nfunction extractSchemaNameFromRef($ref: string): string | undefined {\n if (!$ref.startsWith(COMPONENT_SCHEMAS_PREFIX)) return undefined;\n const raw = $ref.slice(COMPONENT_SCHEMAS_PREFIX.length);\n return decodeURIComponent(raw.replaceAll('~1', '/').replaceAll('~0', '~'));\n}\n\n/**\n * Recursively inlines all `$ref` and `$dynamicRef` references in an OpenAPI\n * schema tree, 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 *\n * `$dynamicRef` is resolved using the dynamic scope attached to `context`:\n * 1. Look up the anchor name in `context.dynamicScope`.\n * 2. If not found, fall back to scanning `components.schemas` for a schema\n * that declares `$dynamicAnchor` with the same name.\n * 3. If resolved to a concrete schema, inline it (same as `$ref`).\n * 4. If unresolved, external, or a generic parameter → return `{}`.\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 if (isDynamicReference(schema)) {\n return dereferenceDynamicRef(schema, context);\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 = buildScopedContext(\n childContext,\n refName,\n resolvedSchema,\n );\n\n if (isDynamicReference(resolvedSchema)) {\n return dereferenceDynamicRef(resolvedSchema, resolvedContext);\n }\n\n return dereferenceProperties(resolvedSchema, resolvedContext);\n};\n\nfunction dereferenceProperties(\n schema: OpenApiSchemaObject,\n context: ContextSpec,\n): OpenApiSchemaObject {\n return Object.entries(schema).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 context,\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, context);\n }\n\n return acc;\n },\n {},\n ) as OpenApiSchemaObject;\n}\n\nfunction buildScopedContext(\n childContext: ContextSpec,\n refName: string | undefined,\n resolvedSchema: OpenApiSchemaObject,\n): ContextSpec {\n if (!refName) return childContext;\n\n const schemaName = extractSchemaNameFromRef(refName);\n if (!schemaName) return childContext;\n\n const schemaRecord = resolvedSchema as Record<string, unknown>;\n const hasDynamicAnchor = typeof schemaRecord.$dynamicAnchor === 'string';\n const defs = schemaRecord.$defs as Record<string, unknown> | undefined;\n const hasDefsAnchors =\n defs &&\n typeof defs === 'object' &&\n Object.values(defs).some(\n (d) => d && typeof d === 'object' && '$dynamicAnchor' in d,\n );\n\n if (!hasDynamicAnchor && !hasDefsAnchors) return childContext;\n\n return {\n ...childContext,\n dynamicScope: buildDynamicScope(schemaName, resolvedSchema, childContext),\n };\n}\n\nfunction dereferenceDynamicRef(\n schema: object & { $dynamicRef: string },\n context: ContextSpec,\n): OpenApiSchemaObject {\n const dynamicRef = schema.$dynamicRef;\n const anchorName = getDynamicAnchorName(dynamicRef);\n if (!anchorName) {\n return {};\n }\n\n const {\n resolvedTypeName,\n schema: resolvedSchema,\n schemaName,\n } = resolveDynamicRef(anchorName, context);\n\n const dynamicRefPath = `$dynamicRef:${dynamicRef}@${schemaName ?? '?'}`;\n if (context.parents?.includes(dynamicRefPath)) {\n return {};\n }\n\n if (resolvedTypeName === 'unknown' || !isObject(resolvedSchema)) {\n return {};\n }\n\n const childContext: ContextSpec = {\n ...context,\n parents: [...(context.parents ?? []), dynamicRefPath],\n };\n\n const scopedContext = buildScopedContext(\n childContext,\n schemaName\n ? `${COMPONENT_SCHEMAS_PREFIX}${encodeSegment(schemaName)}`\n : undefined,\n resolvedSchema,\n );\n\n const siblingProperties = Object.fromEntries(\n Object.entries(schema).filter(([key]) => key !== '$dynamicRef'),\n );\n\n const merged: OpenApiSchemaObject = {\n ...(resolvedSchema as Record<string, unknown>),\n ...siblingProperties,\n } as OpenApiSchemaObject;\n\n return dereferenceProperties(merged, scopedContext);\n}\n\nfunction encodeSegment(segment: string): string {\n return segment.replaceAll('~', '~0').replaceAll('/', '~1');\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 if (parseType === 'response') {\n const textPlainContent = contentEntries.find(\n isMediaType(String.raw`^text\\/plain$`),\n );\n if (textPlainContent) {\n return {\n input: { functions: [['string', undefined]], consts: [] },\n isArray: false,\n };\n }\n }\n\n return {\n input: { functions: [], consts: [] },\n isArray: false,\n };\n }\n\n const encoding = mediaType.encoding;\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 const otherSuccess = Object.entries(responses).find(\n ([code]) => code.startsWith('2') && code !== '204' && code !== '205',\n )?.[1];\n\n return (\n responses['200'] ??\n responses['2XX'] ??\n responses['2xx'] ??\n otherSuccess ??\n responses['204'] ??\n responses['205']\n );\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.param,\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.query,\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.header,\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.body,\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 responses.length === 0\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\n if (!inputResponse.zod) {\n if (!override.zod.generate.response) {\n return [];\n }\n\n const noContentStatusCodes = new Set(['204', '205']);\n const statusCode = responses[index][0];\n const isEachHttpStatusMode = !!statusCode;\n\n let isNoContent: boolean;\n if (isEachHttpStatusMode) {\n isNoContent = noContentStatusCodes.has(statusCode);\n } else {\n const specResponseKeys = new Set(\n Object.keys(spec[verb]?.responses ?? {}),\n );\n const hasStandardSuccess =\n specResponseKeys.has('200') ||\n specResponseKeys.has('2XX') ||\n specResponseKeys.has('2xx');\n isNoContent = !hasStandardSuccess;\n }\n const noContentSchema = isNoContent ? 'zod.void()' : 'zod.unknown()';\n\n return [\n `export const ${operationResponse} = ${noContentSchema}${brand(operationResponse)}`,\n ];\n }\n\n return [\n ...(inputResponse.consts ? [inputResponse.consts] : []),\n parsedResponses[index].isArray\n ? `export const ${operationResponse}Item = ${inputResponse.zod}\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 ].join('\\n\\n'),\n mutators: [\n // Gate each request-side preprocess mutator on its parsed `.zod`: it is\n // computed for every operation once the target is configured, so without\n // this an operation lacking the schema would emit an unused import.\n ...(preprocessParams && inputParams.zod ? [preprocessParams] : []),\n ...(preprocessQueryParams && inputQueryParams.zod\n ? [preprocessQueryParams]\n : []),\n ...(preprocessHeader && inputHeaders.zod ? [preprocessHeader] : []),\n ...(preprocessBody && inputBody.zod ? [preprocessBody] : []),\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;CACzD,OACE,YAAY,kBAAkB,OAC9B,YAAY,cAAc,OAC1B,YAAY,iBAAiB,OAC7B,YAAY,kBAAkB;AAElC;AAEA,MAAa,kBAAkB,gBAA6B;CAC1D,MAAM,UAAU,qBAAqB,WAAW;CAEhD,IAAI,CAAC,SACH,OAAO;CAGT,MAAM,YAAY,QAAQ,MAAM,GAAG,EAAE;CAErC,OAAO,gBAAgB,WAAW,OAAO;AAC3C;AAEA,MAAa,oBAAoB,YAAqB;CACpD,OAAO,UAAU,aAAa;AAChC;AAEA,MAAa,oBAAoB,YAAqB;CACpD,OAAO,UAAU,aAAa;AAChC;AAEA,MAAa,wBAAwB,YAAqB;CACxD,OAAO,UAAU,iBAAiB;AACpC;AAIA,MAAa,yBACX,SACA,QACA,eACwB;CACxB,IAAI,WAAW,QACb,OAAO,CAAC,CAAC,gBAAgB,UAAU,CAAC;MAEpC,OAAO,SACH,CACE,CAAC,UAAU,UAAU,GACrB,CAAC,UAAU,KAAA,CAAS,CACtB,IACA,CAAC,CAAC,UAA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GACF,CAAC;EACH,EAAE,KAAK,MAAM;EACb,UAAU;GAIR,GAAI,oBAAoB,YAAY,MAAM,CAAC,gBAAgB,IAAI,CAAC;GAChE,GAAI,yBAAyB,iBAAiB,MAC1C,CAAC,qBAAqB,IACtB,CAAC;GACL,GAAI,oBAAoB,aAAa,MAAM,CAAC,gBAAgB,IAAI,CAAC;GACjE,GAAI,kBAAkB,UAAU,MAAM,CAAC,cAAc,IAAI,CAAC;GAC1D,GAAI,qBAAqB,CAAC,kBAAkB,IAAI,CAAC;GAMjD,GAAI,gBAAgB,CAAC,aAAa,IAAI,CAAC;EACzC;EACA,UAAU,qBAAqB,8BAAc,IAAI,IAAY;CAC/D;AACF;AAEA,MAAa,cAA6B,OAAO,aAAa,YAAY;CACxE,MAAM,EAAE,gBAAgB,UAAU,aAAa,MAAM,iBACnD,aACA,OACF;CAEA,OAAO;EACL,gBAAgB,iBAAiB,GAAG,eAAe,QAAQ;EAI3D,SAAS,CAAC,GAAG,QAAQ,EAAE,SAAS,EAAE,KAAK,UAAU;GAC/C;GACA,YAAY;GACZ,QAAQ;EACV,EAAE;EACF;CACF;AACF;AAEA,MAAM,mBAA4C;CAChD,QAAQ;CACR,cAAc;AAChB;AAEA,MAAa,sBAAsB"}
package/package.json CHANGED
@@ -1,54 +1,34 @@
1
1
  {
2
2
  "name": "@orval/zod",
3
- "version": "8.14.0",
3
+ "version": "8.16.0",
4
+ "homepage": "https://orval.dev/docs/guides/zod",
5
+ "bugs": {
6
+ "url": "https://github.com/orval-labs/orval/issues"
7
+ },
4
8
  "license": "MIT",
5
9
  "repository": {
6
10
  "type": "git",
7
11
  "url": "git+https://github.com/orval-labs/orval.git",
8
12
  "directory": "packages/zod"
9
13
  },
10
- "homepage": "https://orval.dev/docs/guides/zod",
11
- "bugs": {
12
- "url": "https://github.com/orval-labs/orval/issues"
13
- },
14
- "type": "module",
15
- "types": "./dist/index.d.mts",
16
- "exports": {
17
- ".": {
18
- "development": "./src/index.ts",
19
- "default": "./dist/index.mjs"
20
- },
21
- "./package.json": "./package.json"
22
- },
23
14
  "files": [
24
15
  "dist",
25
16
  "!dist/**/*.d.ts.map",
26
17
  "!dist/**/*.d.mts.map"
27
18
  ],
28
- "scripts": {
29
- "build": "tsdown --config-loader unrun",
30
- "dev": "tsdown --config-loader unrun --watch src",
31
- "lint": "eslint .",
32
- "test": "vitest",
33
- "typecheck": "tsc --noEmit",
34
- "clean": "rimraf .turbo dist",
35
- "nuke": "rimraf .turbo dist node_modules"
19
+ "type": "module",
20
+ "types": "./dist/index.d.mts",
21
+ "exports": {
22
+ ".": "./dist/index.mjs",
23
+ "./package.json": "./package.json"
36
24
  },
37
25
  "dependencies": {
38
- "@orval/core": "8.14.0",
26
+ "@orval/core": "8.16.0",
39
27
  "remeda": "^2.33.6"
40
28
  },
41
29
  "devDependencies": {
42
- "eslint": "10.1.0",
43
30
  "rimraf": "6.1.2",
44
- "tsdown": "0.21.9",
45
31
  "typescript": "5.9.3",
46
32
  "vitest": "4.0.18"
47
- },
48
- "publishConfig": {
49
- "exports": {
50
- ".": "./dist/index.mjs",
51
- "./package.json": "./package.json"
52
- }
53
33
  }
54
34
  }