@orval/core 8.13.0 → 8.15.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.mjs CHANGED
@@ -48,6 +48,7 @@ const OutputClient = {
48
48
  VUE_QUERY: "vue-query",
49
49
  SWR: "swr",
50
50
  ZOD: "zod",
51
+ EFFECT: "effect",
51
52
  HONO: "hono",
52
53
  FETCH: "fetch",
53
54
  MCP: "mcp"
@@ -136,9 +137,12 @@ const TEMPLATE_TAG_REGEX = /\${(.+?)}/g;
136
137
  //#endregion
137
138
  //#region src/utils/assertion.ts
138
139
  /**
139
- * Discriminator helper for `ReferenceObject`
140
+ * Type guard for an OpenAPI {@link OpenApiReferenceObject}.
140
141
  *
141
- * @param property
142
+ * Returns `true` when `obj` has a `$ref` property, indicating a static
143
+ * JSON Pointer reference rather than an inline schema.
144
+ *
145
+ * @param obj - Value to test.
142
146
  */
143
147
  function isReference(obj) {
144
148
  return !isNullish$1(obj) && Object.hasOwn(obj, "$ref");
@@ -149,27 +153,71 @@ function isReference(obj) {
149
153
  * Returns `true` when `obj` has a `$dynamicRef` string property,
150
154
  * indicating it is an OpenAPI 3.1 dynamic reference rather than a
151
155
  * static `$ref`.
156
+ *
157
+ * @param obj - Value to test.
158
+ *
159
+ * @see https://json-schema.org/draft/2020-12/json-schema-core#section-8.2.4
152
160
  */
153
161
  function isDynamicReference(obj) {
154
162
  return !isNullish$1(obj) && Object.hasOwn(obj, "$dynamicRef") && typeof obj.$dynamicRef === "string";
155
163
  }
164
+ /**
165
+ * Returns `true` when `pathValue` has no file extension and is treated as a
166
+ * directory path.
167
+ *
168
+ * @param pathValue - Path string to inspect.
169
+ */
156
170
  function isDirectory(pathValue) {
157
171
  return !nodePath.extname(pathValue);
158
172
  }
173
+ /**
174
+ * Type guard for plain objects created with `{}` or `new Object()`.
175
+ *
176
+ * Excludes `null`, arrays, dates, and other non-plain object values.
177
+ *
178
+ * @param x - Value to test.
179
+ */
159
180
  function isObject(x) {
160
181
  return Object.prototype.toString.call(x) === "[object Object]";
161
182
  }
183
+ /**
184
+ * Type guard for string primitives and `String` wrapper objects.
185
+ *
186
+ * @param val - Value to test.
187
+ */
162
188
  function isStringLike(val) {
163
189
  if (isString$1(val)) return true;
164
190
  return Object.prototype.toString.call(val) === "[object String]";
165
191
  }
192
+ /**
193
+ * Type guard for ES module namespace objects.
194
+ *
195
+ * @param x - Value to test.
196
+ */
166
197
  function isModule(x) {
167
198
  return Object.prototype.toString.call(x) === "[object Module]";
168
199
  }
200
+ /**
201
+ * Type guard for integer numbers and numeric strings.
202
+ *
203
+ * Accepts finite integers (`42`) and strings that match `/^-?\d+$/`
204
+ * (`"-1"`, `"0"`). Rejects floats, empty strings, and non-numeric values.
205
+ *
206
+ * @param x - Value to test.
207
+ */
169
208
  function isNumeric(x) {
170
209
  if (typeof x === "number") return Number.isInteger(x);
171
210
  return isString$1(x) && /^-?\d+$/.test(x);
172
211
  }
212
+ /**
213
+ * Type guard for an inline OpenAPI {@link OpenApiSchemaObject}.
214
+ *
215
+ * Returns `true` when `x` looks like a schema definition: it has a known
216
+ * `type`, composition keywords (`allOf`, `anyOf`, `oneOf`), or `properties`.
217
+ * Does not match reference objects; use {@link isReference} for those.
218
+ *
219
+ * @param x - Value to test.
220
+ */
173
221
  function isSchema(x) {
174
222
  if (!isObject(x)) return false;
175
223
  if (isString$1(x.type) && Object.values(SchemaType).includes(x.type)) return true;
@@ -178,9 +226,22 @@ function isSchema(x) {
178
226
  if (isObject(x.properties)) return true;
179
227
  return false;
180
228
  }
229
+ /**
230
+ * Type guard for HTTP methods defined in {@link Verbs}.
231
+ *
232
+ * @param verb - Method name to test (for example, `"get"`, `"post"`).
233
+ */
181
234
  function isVerb(verb) {
182
235
  return Object.values(Verbs).includes(verb);
183
236
  }
237
+ /**
238
+ * Returns `true` when `str` is a valid absolute URL with an `http:` or
239
+ * `https:` protocol.
240
+ *
241
+ * Empty or whitespace-only strings are rejected.
242
+ *
243
+ * @param str - URL string to validate.
244
+ */
184
245
  function isUrl(str) {
185
246
  if (!str.trim()) return false;
186
247
  try {
@@ -193,6 +254,8 @@ function isUrl(str) {
193
254
  /**
194
255
  * Type guard for the MSW mock generator. Use to narrow a
195
256
  * `GlobalMockOptions | ClientMockBuilder` value to `MswMockOptions`.
257
+ *
258
+ * @param mock - Mock configuration or builder to test.
196
259
  */
197
260
  function isMswMock(mock) {
198
261
  return !isFunction$1(mock) && mock.type === OutputMockType.MSW;
@@ -200,6 +263,8 @@ function isMswMock(mock) {
200
263
  /**
201
264
  * Type guard for the Faker mock generator. Use to narrow a
202
265
  * `GlobalMockOptions | ClientMockBuilder` value to `FakerMockOptions`.
266
+ *
267
+ * @param mock - Mock configuration or builder to test.
203
268
  */
204
269
  function isFakerMock(mock) {
205
270
  return !isFunction$1(mock) && mock.type === OutputMockType.FAKER;
@@ -266,10 +331,11 @@ const pascalMemory = {};
266
331
  function pascal(s = "") {
267
332
  if (pascalMemory[s]) return pascalMemory[s];
268
333
  const isStartWithUnderscore = s.startsWith("_");
334
+ const cacheKey = s;
269
335
  if (regexps.upper.test(s)) s = low(s);
270
336
  const pascalString = (s.match(/[a-zA-Z0-9\u00C0-\u017F]+/g) ?? []).map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join("");
271
337
  const pascalWithUnderscore = isStartWithUnderscore ? `_${pascalString}` : pascalString;
272
- pascalMemory[s] = pascalWithUnderscore;
338
+ pascalMemory[cacheKey] = pascalWithUnderscore;
273
339
  return pascalWithUnderscore;
274
340
  }
275
341
  function camel(s = "") {
@@ -393,6 +459,20 @@ function createDebugger(ns, options = {}) {
393
459
  const search = String.raw`\*/`;
394
460
  const replacement = String.raw`*\/`;
395
461
  const regex = new RegExp(search, "g");
462
+ function trimTrailingEmptyLines(lines) {
463
+ let lastLineIndex = lines.length - 1;
464
+ while (lastLineIndex >= 0 && lines[lastLineIndex]?.trim() === "") lastLineIndex--;
465
+ return lines.slice(0, lastLineIndex + 1);
466
+ }
467
+ function escapeJsDoc(value) {
468
+ return value.replaceAll(regex, replacement);
469
+ }
470
+ function getDescriptionLines(description) {
471
+ return trimTrailingEmptyLines((Array.isArray(description) ? description.filter((line) => !line.includes("eslint-disable")) : [description ?? ""]).flatMap((block) => block.split(/\r?\n/).map((line) => escapeJsDoc(line))));
472
+ }
473
+ function getEslintDisable(description) {
474
+ return Array.isArray(description) ? description.find((line) => line.includes("eslint-disable")) : void 0;
475
+ }
396
476
  const itemValidationKeys = [
397
477
  "minLength",
398
478
  "maxLength",
@@ -416,93 +496,56 @@ function getItemValidationDocEntries(schema, prefix = "items", visited = /* @__P
416
496
  }];
417
497
  }), ...getItemValidationDocEntries(schema.items, `${prefix}.items`, visited)];
418
498
  }
499
+ function toJsDocEntry(key, value) {
500
+ if (value === void 0 || value === false || value === "") return [];
501
+ return [{
502
+ key,
503
+ value
504
+ }];
505
+ }
506
+ function getSchemaDocEntries(schema, itemValidationDocEntries, isNullable) {
507
+ const { deprecated, summary, minLength, maxLength, minimum, maximum, exclusiveMinimum, exclusiveMaximum, minItems, maxItems, pattern } = schema;
508
+ return [
509
+ ...toJsDocEntry("deprecated", deprecated),
510
+ ...toJsDocEntry("summary", summary),
511
+ ...toJsDocEntry("minLength", minLength),
512
+ ...toJsDocEntry("maxLength", maxLength),
513
+ ...toJsDocEntry("minimum", minimum),
514
+ ...toJsDocEntry("maximum", maximum),
515
+ ...toJsDocEntry("exclusiveMinimum", exclusiveMinimum),
516
+ ...toJsDocEntry("exclusiveMaximum", exclusiveMaximum),
517
+ ...toJsDocEntry("minItems", minItems),
518
+ ...toJsDocEntry("maxItems", maxItems),
519
+ ...toJsDocEntry("nullable", isNullable),
520
+ ...toJsDocEntry("pattern", pattern),
521
+ ...itemValidationDocEntries.flatMap(({ key, value }) => toJsDocEntry(key, value))
522
+ ];
523
+ }
524
+ function formatJsDocEntry({ key, value }) {
525
+ if (value === true) return `@${key}`;
526
+ return `@${key} ${escapeJsDoc(value.toString())}`;
527
+ }
528
+ function renderJsDocBlock(lines, tryOneLine = false) {
529
+ if (lines.length === 0) return "";
530
+ if (lines.length === 1 && tryOneLine) return `/** ${lines[0]} */\n`;
531
+ const linePrefix = `${tryOneLine ? " " : ""} *`;
532
+ const closingPrefix = ` ${tryOneLine ? " " : ""}`;
533
+ return `/**\n${lines.map((line) => `${linePrefix}${line ? ` ${line}` : ""}`).join("\n")}\n${closingPrefix}*/\n`;
534
+ }
419
535
  function jsDoc(schema, tryOneLine = false, context) {
420
536
  if (context?.output.override.jsDoc) {
421
537
  const { filter } = context.output.override.jsDoc;
422
538
  if (filter) return keyValuePairsToJsDoc(filter(schema));
423
539
  }
424
- const { description, deprecated, summary, minLength, maxLength, minimum, maximum, exclusiveMinimum, exclusiveMaximum, minItems, maxItems, pattern } = schema;
425
540
  const isNullable = schema.type === "null" || Array.isArray(schema.type) && schema.type.includes("null");
426
541
  const itemValidationDocEntries = getItemValidationDocEntries(schema.items);
427
- const lines = (Array.isArray(description) ? description.filter((d) => !d.includes("eslint-disable")) : [description ?? ""]).flatMap((line) => line.split(/\r?\n/)).map((line) => line.replaceAll(regex, replacement));
428
- const count = [
429
- description,
430
- deprecated,
431
- summary,
432
- minLength?.toString(),
433
- maxLength?.toString(),
434
- minimum?.toString(),
435
- maximum?.toString(),
436
- exclusiveMinimum?.toString(),
437
- exclusiveMaximum?.toString(),
438
- minItems?.toString(),
439
- maxItems?.toString(),
440
- isNullable ? "null" : "",
441
- pattern,
442
- ...itemValidationDocEntries.map(({ value }) => value.toString())
443
- ].filter(Boolean).length;
444
- if (!count) return "";
445
- const oneLine = count === 1 && tryOneLine;
446
- const eslintDisable = Array.isArray(description) ? description.find((d) => d.includes("eslint-disable"))?.replaceAll(regex, replacement) : void 0;
447
- let doc = `${eslintDisable ? `/* ${eslintDisable} */\n` : ""}/**`;
448
- if (description) {
449
- if (!oneLine) doc += `\n${tryOneLine ? " " : ""} *`;
450
- doc += ` ${lines.join("\n * ")}`;
451
- }
452
- function appendPrefix() {
453
- if (!oneLine) doc += `\n${tryOneLine ? " " : ""} *`;
454
- }
455
- function tryAppendStringDocLine(key, value) {
456
- if (value) {
457
- appendPrefix();
458
- doc += ` @${key} ${value.replaceAll(regex, replacement)}`;
459
- }
460
- }
461
- function tryAppendBooleanDocLine(key, value) {
462
- if (value === true) {
463
- appendPrefix();
464
- doc += ` @${key}`;
465
- }
466
- }
467
- function tryAppendNumberDocLine(key, value) {
468
- if (value !== void 0) {
469
- appendPrefix();
470
- doc += ` @${key} ${value}`;
471
- }
472
- }
473
- tryAppendBooleanDocLine("deprecated", deprecated);
474
- tryAppendStringDocLine("summary", summary?.replaceAll(regex, replacement));
475
- tryAppendNumberDocLine("minLength", minLength);
476
- tryAppendNumberDocLine("maxLength", maxLength);
477
- tryAppendNumberDocLine("minimum", minimum);
478
- tryAppendNumberDocLine("maximum", maximum);
479
- tryAppendNumberDocLine("exclusiveMinimum", exclusiveMinimum);
480
- tryAppendNumberDocLine("exclusiveMaximum", exclusiveMaximum);
481
- tryAppendNumberDocLine("minItems", minItems);
482
- tryAppendNumberDocLine("maxItems", maxItems);
483
- tryAppendBooleanDocLine("nullable", isNullable);
484
- tryAppendStringDocLine("pattern", pattern);
485
- for (const { key, value } of itemValidationDocEntries) {
486
- if (typeof value === "string") {
487
- tryAppendStringDocLine(key, value);
488
- continue;
489
- }
490
- if (typeof value === "number") {
491
- tryAppendNumberDocLine(key, value);
492
- continue;
493
- }
494
- tryAppendBooleanDocLine(key, value);
495
- }
496
- doc += oneLine ? " " : `\n ${tryOneLine ? " " : ""}`;
497
- doc += "*/\n";
498
- return doc;
542
+ const lines = [...getDescriptionLines(schema.description), ...getSchemaDocEntries(schema, itemValidationDocEntries, isNullable).map((entry) => formatJsDocEntry(entry))];
543
+ const eslintDisable = getEslintDisable(schema.description);
544
+ const doc = renderJsDocBlock(lines, tryOneLine);
545
+ return `${eslintDisable ? `/* ${escapeJsDoc(eslintDisable)} */\n` : ""}${doc}`;
499
546
  }
500
547
  function keyValuePairsToJsDoc(keyValues) {
501
- if (keyValues.length === 0) return "";
502
- let doc = "/**\n";
503
- for (const { key, value } of keyValues) doc += ` * @${key} ${value}\n`;
504
- doc += " */\n";
505
- return doc;
548
+ return renderJsDocBlock(keyValues.map(({ key, value }) => `@${key} ${value}`));
506
549
  }
507
550
  //#endregion
508
551
  //#region src/utils/dynamic-import.ts
@@ -665,9 +708,6 @@ const LogLevels = {
665
708
  warn: 2,
666
709
  info: 3
667
710
  };
668
- let lastType;
669
- let lastMsg;
670
- let sameCount = 0;
671
711
  function clearScreen() {
672
712
  const repeatCount = process.stdout.rows - 2;
673
713
  const blank = repeatCount > 0 ? "\n".repeat(repeatCount) : "";
@@ -677,6 +717,9 @@ function clearScreen() {
677
717
  }
678
718
  function createLogger(level = "info", options = {}) {
679
719
  const { prefix = "[vite]", allowClearScreen = true } = options;
720
+ let lastType;
721
+ let lastMsg;
722
+ let sameCount = 0;
680
723
  const thresh = LogLevels[level];
681
724
  const clear = allowClearScreen && process.stdout.isTTY && !process.env.CI ? clearScreen : () => {};
682
725
  function output(type, msg, options = {}) {
@@ -1239,7 +1282,7 @@ const getUnion = (value, enumName) => {
1239
1282
  };
1240
1283
  function getEnumUnionFromSchema(schema) {
1241
1284
  if (!schema?.enum) return "";
1242
- return schema.enum.filter((val) => val !== null).map((val) => isString(val) ? `'${escape(val)}'` : String(val)).join(" | ");
1285
+ return schema.enum.filter((val) => val !== null).map((val) => isString(val) ? `'${jsStringEscape(val)}'` : String(val)).join(" | ");
1243
1286
  }
1244
1287
  const stripNullUnion = (value) => value.replaceAll(/\s*\|\s*null/g, "").trim();
1245
1288
  const isSpreadableEnumRef = (schema, refName) => {
@@ -1626,13 +1669,13 @@ function getPropertyNamesEnumKeyType(item) {
1626
1669
  if (Array.isArray(propertyNames.enum)) {
1627
1670
  const enumValues = propertyNames.enum.filter((val) => isString(val));
1628
1671
  if (enumValues.length > 0) return {
1629
- value: enumValues.map((val) => `'${escape(val)}'`).join(" | "),
1672
+ value: enumValues.map((val) => `'${jsStringEscape(val)}'`).join(" | "),
1630
1673
  imports: [],
1631
1674
  dependencies: []
1632
1675
  };
1633
1676
  }
1634
1677
  if (isString(propertyNames.const)) return {
1635
- value: `'${escape(propertyNames.const)}'`,
1678
+ value: `'${jsStringEscape(propertyNames.const)}'`,
1636
1679
  imports: [],
1637
1680
  dependencies: []
1638
1681
  };
@@ -1771,7 +1814,7 @@ function getObject({ item, name, context, nullable, formDataContext }) {
1771
1814
  const hasConst = constValue !== void 0;
1772
1815
  let constLiteral;
1773
1816
  if (!hasConst) constLiteral = void 0;
1774
- else if (isString(constValue)) constLiteral = `'${escape(constValue)}'`;
1817
+ else if (isString(constValue)) constLiteral = `'${jsStringEscape(constValue)}'`;
1775
1818
  else constLiteral = JSON.stringify(constValue);
1776
1819
  const needsValueImport = hasConst && (resolvedValue.isEnum || resolvedValue.type === "enum");
1777
1820
  const usedResolvedValue = !hasConst || needsValueImport;
@@ -1904,7 +1947,7 @@ function getObject({ item, name, context, nullable, formDataContext }) {
1904
1947
  else if (typeof constValue === "boolean") type = "boolean";
1905
1948
  else type = "object";
1906
1949
  return {
1907
- value: typeof constValue === "string" ? `'${escape(constValue)}'` : JSON.stringify(constValue),
1950
+ value: typeof constValue === "string" ? `'${jsStringEscape(constValue)}'` : JSON.stringify(constValue),
1908
1951
  imports: [],
1909
1952
  schemas: [],
1910
1953
  isEnum: false,
@@ -2045,7 +2088,7 @@ function getScalar({ item, name, context, formDataContext }) {
2045
2088
  let value = "string";
2046
2089
  let isEnum = false;
2047
2090
  if (enumItems) {
2048
- value = enumItems.map((enumItem) => isString(enumItem) ? `'${escape(enumItem)}'` : `${enumItem}`).filter(Boolean).join(` | `);
2091
+ value = enumItems.map((enumItem) => isString(enumItem) ? `'${jsStringEscape(enumItem)}'` : `${enumItem}`).filter(Boolean).join(` | `);
2049
2092
  isEnum = true;
2050
2093
  }
2051
2094
  if (!formDataContext?.urlEncoded) {
@@ -2107,7 +2150,7 @@ function getScalar({ item, name, context, formDataContext }) {
2107
2150
  nullable
2108
2151
  });
2109
2152
  if (enumItems) return {
2110
- value: enumItems.map((enumItem) => isString(enumItem) ? `'${escape(enumItem)}'` : String(enumItem)).filter(Boolean).join(` | `) + nullable,
2153
+ value: enumItems.map((enumItem) => isString(enumItem) ? `'${jsStringEscape(enumItem)}'` : String(enumItem)).filter(Boolean).join(` | `) + nullable,
2111
2154
  isEnum: true,
2112
2155
  type: "string",
2113
2156
  imports: [],
@@ -2385,27 +2428,33 @@ function resolveDynamicRef(anchorName, context, imports = []) {
2385
2428
  let scopeEntry = (context.dynamicScope ?? {})[anchorName];
2386
2429
  if (!scopeEntry) {
2387
2430
  const schemas = context.spec.components?.schemas;
2388
- if (schemas && typeof schemas === "object") for (const [schemaName, schemaObj] of Object.entries(schemas)) {
2389
- if (!schemaObj || typeof schemaObj !== "object") continue;
2390
- if (schemaObj.$dynamicAnchor === anchorName) {
2391
- const refInfo = getRefInfo(`#/components/schemas/${encodeJsonPointerSegment(schemaName)}`, context);
2431
+ if (schemas && typeof schemas === "object") {
2432
+ const matches = [];
2433
+ for (const [schemaName, schemaObj] of Object.entries(schemas)) {
2434
+ if (!schemaObj || typeof schemaObj !== "object") continue;
2435
+ if (schemaObj.$dynamicAnchor === anchorName) matches.push(schemaName);
2436
+ }
2437
+ const match = matches.length === 1 ? matches[0] : matches.find((m) => m === anchorName);
2438
+ if (match) {
2439
+ const refInfo = getRefInfo(`#/components/schemas/${encodeJsonPointerSegment(match)}`, context);
2392
2440
  scopeEntry = {
2393
2441
  name: refInfo.name,
2394
2442
  schemaName: refInfo.originalName
2395
2443
  };
2396
- break;
2397
2444
  }
2398
2445
  }
2399
2446
  }
2400
2447
  if (!scopeEntry) return {
2401
2448
  schema: {},
2402
2449
  imports,
2403
- resolvedTypeName: "unknown"
2450
+ resolvedTypeName: "unknown",
2451
+ schemaName: void 0
2404
2452
  };
2405
2453
  if (scopeEntry.isParameter) return {
2406
2454
  schema: {},
2407
2455
  imports,
2408
- resolvedTypeName: scopeEntry.name
2456
+ resolvedTypeName: scopeEntry.name,
2457
+ schemaName: void 0
2409
2458
  };
2410
2459
  const resolvedTypeName = scopeEntry.name;
2411
2460
  const schemaRef = `#/components/schemas/${encodeJsonPointerSegment(scopeEntry.schemaName)}`;
@@ -2414,13 +2463,15 @@ function resolveDynamicRef(anchorName, context, imports = []) {
2414
2463
  return {
2415
2464
  schema: resolvedSchema,
2416
2465
  imports: resolvedImports,
2417
- resolvedTypeName
2466
+ resolvedTypeName,
2467
+ schemaName: scopeEntry.schemaName
2418
2468
  };
2419
2469
  } catch {
2420
2470
  return {
2421
2471
  schema: {},
2422
2472
  imports,
2423
- resolvedTypeName: "unknown"
2473
+ resolvedTypeName: "unknown",
2474
+ schemaName: void 0
2424
2475
  };
2425
2476
  }
2426
2477
  }
@@ -2595,25 +2646,44 @@ function resolveValue({ schema, name, context, formDataContext }) {
2595
2646
  const resolvedImport = imports[0];
2596
2647
  let hasReadonlyProps = false;
2597
2648
  const refName = resolvedImport.name;
2598
- if (!context.parents?.includes(refName) && hasScopeAffectedDynamicRef(schemaObject, context, refName)) return {
2649
+ let effectiveContext = context;
2650
+ const refAnchor = schemaObject.$dynamicAnchor;
2651
+ if (typeof refAnchor === "string" && context.dynamicScope?.[refAnchor] && context.dynamicScope[refAnchor].name !== refName && !context.dynamicScope[refAnchor].isParameter) {
2652
+ const scopeEntry = context.dynamicScope[refAnchor];
2653
+ const allOf = ((context.spec.components?.schemas)?.[scopeEntry.schemaName])?.allOf;
2654
+ if (!(Array.isArray(allOf) && allOf.some((el) => {
2655
+ if (!el || typeof el !== "object") return false;
2656
+ const rec = el;
2657
+ if (typeof rec.$ref !== "string" || !isComponentRef(rec.$ref)) return false;
2658
+ const { name } = getRefInfo(rec.$ref, context);
2659
+ return name === refName;
2660
+ }))) {
2661
+ const filteredScope = Object.fromEntries(Object.entries(context.dynamicScope).filter(([key]) => key !== refAnchor));
2662
+ effectiveContext = {
2663
+ ...context,
2664
+ dynamicScope: filteredScope
2665
+ };
2666
+ }
2667
+ }
2668
+ if (!effectiveContext.parents?.includes(refName) && hasScopeAffectedDynamicRef(schemaObject, effectiveContext, refName)) return {
2599
2669
  ...getScalar({
2600
2670
  item: schemaObject,
2601
2671
  name: name ?? refName,
2602
2672
  context: {
2603
- ...context,
2604
- parents: [...context.parents ?? [], refName]
2673
+ ...effectiveContext,
2674
+ parents: [...effectiveContext.parents ?? [], refName]
2605
2675
  },
2606
2676
  formDataContext
2607
2677
  }),
2608
2678
  originalSchema: schemaObject,
2609
2679
  isRef: false
2610
2680
  };
2611
- if (!context.parents?.includes(refName)) hasReadonlyProps = getScalar({
2681
+ if (!effectiveContext.parents?.includes(refName)) hasReadonlyProps = getScalar({
2612
2682
  item: schemaObject,
2613
2683
  name: refName,
2614
2684
  context: {
2615
- ...context,
2616
- parents: [...context.parents ?? [], refName]
2685
+ ...effectiveContext,
2686
+ parents: [...effectiveContext.parents ?? [], refName]
2617
2687
  }
2618
2688
  }).hasReadonlyProps;
2619
2689
  const isAnyOfNullable = schemaObject.anyOf?.some((anyOfItem) => !isReference(anyOfItem) && (anyOfItem.type === "null" || Array.isArray(anyOfItem.type) && anyOfItem.type.includes("null")));
@@ -3416,9 +3486,13 @@ function resolveDiscriminators(schemas, context) {
3416
3486
  }
3417
3487
  for (const [parentName, parentSchema] of Object.entries(transformedSchemas)) {
3418
3488
  if (isBoolean$1(parentSchema)) continue;
3419
- if (!parentSchema.oneOf || !parentSchema.discriminator?.mapping) continue;
3420
- const { mapping, propertyName } = parentSchema.discriminator;
3489
+ const variants = parentSchema.oneOf ?? parentSchema.anyOf;
3490
+ if (!variants || !parentSchema.discriminator) continue;
3491
+ const { propertyName, mapping } = parentSchema.discriminator;
3421
3492
  if (!propertyName) continue;
3493
+ const mappedRefs = mapping ? Object.values(mapping) : [];
3494
+ const variantArrayRefs = variants.filter((item) => isReference(item) && typeof item.$ref === "string").map((item) => item.$ref);
3495
+ const variantRefs = [...new Set([...mappedRefs, ...variantArrayRefs])];
3422
3496
  const parentProperties = parentSchema.properties;
3423
3497
  const parentRequired = parentSchema.required;
3424
3498
  const inheritableProps = {};
@@ -3427,7 +3501,7 @@ function resolveDiscriminators(schemas, context) {
3427
3501
  }
3428
3502
  const inheritableRequired = parentRequired?.filter((key) => key !== propertyName);
3429
3503
  const hasInheritableProps = Object.keys(inheritableProps).length > 0;
3430
- for (const mappingValue of Object.values(mapping)) {
3504
+ for (const mappingValue of variantRefs) {
3431
3505
  let variantSchema;
3432
3506
  try {
3433
3507
  const { originalName } = getRefInfo(mappingValue, context);
@@ -4017,14 +4091,17 @@ function hasCircularReference(target, sourceName, context, visited = /* @__PURE_
4017
4091
  function buildPayload(target, context, parents, imports) {
4018
4092
  if (isReference$1(target)) return buildRefPayload(target, context, parents, imports);
4019
4093
  const schema = target;
4020
- if (schema.allOf) return buildAllOfPayload(getSchemas(schema.allOf) ?? [], context, parents, imports);
4021
- if (schema.oneOf) return buildFirstOfPayload(getSchemas(schema.oneOf) ?? [], context, parents, imports);
4022
- if (schema.anyOf) return buildFirstOfPayload(getSchemas(schema.anyOf) ?? [], context, parents, imports);
4094
+ const payloads = [];
4095
+ if (schema.allOf) payloads.push(buildAllOfPayload(getSchemas(schema.allOf) ?? [], context, parents, imports));
4096
+ else if (schema.oneOf) payloads.push(buildFirstOfPayload(getSchemas(schema.oneOf) ?? [], context, parents, imports));
4097
+ else if (schema.anyOf) payloads.push(buildFirstOfPayload(getSchemas(schema.anyOf) ?? [], context, parents, imports));
4098
+ if (Object.keys(getProperties(schema)).length > 0) payloads.push(buildObjectPayload(schema, context, parents, imports));
4099
+ if (payloads.length > 0) return payloads.length === 1 ? payloads[0] : `Object.assign({}, ${payloads.join(", ")})`;
4023
4100
  const { constValue } = getExtendedProps(schema);
4024
4101
  if (constValue !== void 0) return formatValue(constValue);
4025
4102
  if (schema.default !== void 0) return buildDefaultPayload(schema, context);
4026
4103
  const schemaType = inferSchemaType(schema);
4027
- if (schemaType === "object" || schema.properties) return buildObjectPayload(schema, context, parents, imports);
4104
+ if (schemaType === "object") return "{}";
4028
4105
  if (schemaType === "array") return buildArrayPayload(schema, context, parents, imports);
4029
4106
  return buildPrimitivePayload(schema, schemaType, context);
4030
4107
  }
@@ -4399,6 +4476,9 @@ function parseFile(file, name) {
4399
4476
  return;
4400
4477
  }
4401
4478
  }
4479
+ function standardMutatorInfo() {
4480
+ return { numberOfParams: 1 };
4481
+ }
4402
4482
  function parseFunction(ast, funcName) {
4403
4483
  const node = ast.body.find((childNode) => {
4404
4484
  if (childNode.type === "VariableDeclaration") return childNode.declarations.find((d) => d.id.type === "Identifier" && d.id.name === funcName);
@@ -4423,6 +4503,7 @@ function parseFunction(ast, funcName) {
4423
4503
  const declaration = "declarations" in node ? node.declarations.find((d) => d.id.type === "Identifier" && d.id.name === funcName) : void 0;
4424
4504
  if (declaration?.init) {
4425
4505
  if ("name" in declaration.init) return parseFunction(ast, declaration.init.name);
4506
+ if (declaration.init.type === "CallExpression") return standardMutatorInfo();
4426
4507
  if ("body" in declaration.init && "params" in declaration.init && declaration.init.body.type === "ArrowFunctionExpression") return {
4427
4508
  numberOfParams: declaration.init.params.length,
4428
4509
  returnNumberOfParams: declaration.init.body.params.length