@orval/core 7.9.0 → 7.11.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.js CHANGED
@@ -6594,6 +6594,7 @@ function createScanner(text, ignoreTrivia) {
6594
6594
  return token = 14;
6595
6595
  }
6596
6596
  switch (code) {
6597
+ // tokens: []{}:,
6597
6598
  case 123:
6598
6599
  pos++;
6599
6600
  return token = 1;
@@ -6612,10 +6613,12 @@ function createScanner(text, ignoreTrivia) {
6612
6613
  case 44:
6613
6614
  pos++;
6614
6615
  return token = 5;
6616
+ // strings
6615
6617
  case 34:
6616
6618
  pos++;
6617
6619
  value = scanString();
6618
6620
  return token = 10;
6621
+ // comments
6619
6622
  case 47:
6620
6623
  var start = pos - 1;
6621
6624
  if (text.charCodeAt(pos + 1) === 47) {
@@ -6659,12 +6662,16 @@ function createScanner(text, ignoreTrivia) {
6659
6662
  value += String.fromCharCode(code);
6660
6663
  pos++;
6661
6664
  return token = 16;
6665
+ // numbers
6662
6666
  case 45:
6663
6667
  value += String.fromCharCode(code);
6664
6668
  pos++;
6665
6669
  if (pos === len || !isDigit(text.charCodeAt(pos))) {
6666
6670
  return token = 16;
6667
6671
  }
6672
+ // found a minus, followed by a number so
6673
+ // we fall through to proceed with scanning
6674
+ // numbers
6668
6675
  case 48:
6669
6676
  case 49:
6670
6677
  case 50:
@@ -6677,6 +6684,7 @@ function createScanner(text, ignoreTrivia) {
6677
6684
  case 57:
6678
6685
  value += scanNumber();
6679
6686
  return token = 11;
6687
+ // literals and unknown symbols
6680
6688
  default:
6681
6689
  while (pos < len && isUnknownContentCharacter(code)) {
6682
6690
  pos++;
@@ -24963,6 +24971,7 @@ var require_immer_cjs_development = __commonJS({
24963
24971
  switch (type) {
24964
24972
  case 2:
24965
24973
  return base2.set(key, value);
24974
+ /* istanbul ignore next */
24966
24975
  case 3:
24967
24976
  die(16);
24968
24977
  default:
@@ -27628,6 +27637,7 @@ var require_URI = __commonJS({
27628
27637
  switch (getType(value)) {
27629
27638
  case "Undefined":
27630
27639
  return name in data;
27640
+ // data[name] !== undefined;
27631
27641
  case "Boolean":
27632
27642
  var _booly = Boolean(isArray(data[name]) ? data[name].length : data[name]);
27633
27643
  return value === _booly;
@@ -27649,6 +27659,7 @@ var require_URI = __commonJS({
27649
27659
  return arrayContains(data[name], value);
27650
27660
  case "Number":
27651
27661
  value = String(value);
27662
+ /* falls through */
27652
27663
  case "String":
27653
27664
  if (!isArray(data[name])) {
27654
27665
  return data[name] === value;
@@ -27942,6 +27953,7 @@ var require_URI = __commonJS({
27942
27953
  return relative;
27943
27954
  case "absolute":
27944
27955
  return !relative;
27956
+ // hostname identification
27945
27957
  case "domain":
27946
27958
  case "name":
27947
27959
  return name;
@@ -32546,6 +32558,7 @@ var require_index_node_cjs = __commonJS({
32546
32558
  addType = true;
32547
32559
  }
32548
32560
  break;
32561
+ /* c8 ignore next 2 */
32549
32562
  default:
32550
32563
  throw new TypeError("Unknown value type " + valueType);
32551
32564
  }
@@ -41722,6 +41735,7 @@ var require_minimatch = __commonJS({
41722
41735
  continue;
41723
41736
  }
41724
41737
  switch (c2) {
41738
+ /* istanbul ignore next */
41725
41739
  case "/": {
41726
41740
  return false;
41727
41741
  }
@@ -41729,6 +41743,8 @@ var require_minimatch = __commonJS({
41729
41743
  clearStateChar();
41730
41744
  escaping = true;
41731
41745
  continue;
41746
+ // the various stateChar values
41747
+ // for the "extglob" stuff.
41732
41748
  case "?":
41733
41749
  case "*":
41734
41750
  case "+":
@@ -41789,6 +41805,7 @@ var require_minimatch = __commonJS({
41789
41805
  clearStateChar();
41790
41806
  re2 += "|";
41791
41807
  continue;
41808
+ // these are mostly the same in regexp and glob
41792
41809
  case "[":
41793
41810
  clearStateChar();
41794
41811
  if (inClass) {
@@ -44302,7 +44319,7 @@ var require_get_intrinsic = __commonJS({
44302
44319
  if (!allowMissing) {
44303
44320
  throw new $TypeError("base intrinsic for " + name + " exists, but the property is not available.");
44304
44321
  }
44305
- return void 0;
44322
+ return void undefined2;
44306
44323
  }
44307
44324
  if ($gOPD && i3 + 1 >= parts.length) {
44308
44325
  var desc = $gOPD(value, part);
@@ -48109,8 +48126,8 @@ var require_dist10 = __commonJS({
48109
48126
  });
48110
48127
 
48111
48128
  // src/index.ts
48112
- var src_exports = {};
48113
- __export(src_exports, {
48129
+ var index_exports = {};
48130
+ __export(index_exports, {
48114
48131
  BODY_TYPE_NAME: () => BODY_TYPE_NAME,
48115
48132
  EnumGeneration: () => EnumGeneration,
48116
48133
  FormDataArrayHandling: () => FormDataArrayHandling,
@@ -48167,6 +48184,7 @@ __export(src_exports, {
48167
48184
  getArray: () => getArray,
48168
48185
  getBody: () => getBody,
48169
48186
  getEnum: () => getEnum,
48187
+ getEnumDescriptions: () => getEnumDescriptions,
48170
48188
  getEnumImplementation: () => getEnumImplementation,
48171
48189
  getEnumNames: () => getEnumNames,
48172
48190
  getExtension: () => getExtension,
@@ -48190,6 +48208,7 @@ __export(src_exports, {
48190
48208
  getRoute: () => getRoute,
48191
48209
  getRouteAsArray: () => getRouteAsArray,
48192
48210
  getScalar: () => getScalar,
48211
+ getTypedResponse: () => getTypedResponse,
48193
48212
  ibmOpenapiValidator: () => ibmOpenapiValidator,
48194
48213
  ibmOpenapiValidatorErrors: () => ibmOpenapiValidatorErrors,
48195
48214
  ibmOpenapiValidatorWarnings: () => ibmOpenapiValidatorWarnings,
@@ -48212,6 +48231,7 @@ __export(src_exports, {
48212
48231
  jsDoc: () => jsDoc,
48213
48232
  jsStringEscape: () => jsStringEscape,
48214
48233
  kebab: () => kebab,
48234
+ keyValuePairsToJsDoc: () => keyValuePairsToJsDoc,
48215
48235
  loadFile: () => loadFile,
48216
48236
  log: () => log,
48217
48237
  logError: () => logError,
@@ -48242,7 +48262,7 @@ __export(src_exports, {
48242
48262
  writeSplitTagsMode: () => writeSplitTagsMode,
48243
48263
  writeTagsMode: () => writeTagsMode
48244
48264
  });
48245
- module.exports = __toCommonJS(src_exports);
48265
+ module.exports = __toCommonJS(index_exports);
48246
48266
 
48247
48267
  // src/types.ts
48248
48268
  var PropertySortOrder = {
@@ -49071,21 +49091,28 @@ var compareVersions = (firstVersion, secondVersions, operator = ">=") => {
49071
49091
  var search = "\\*/";
49072
49092
  var replacement = "*\\/";
49073
49093
  var regex = new RegExp(search, "g");
49074
- function jsDoc({
49075
- description,
49076
- deprecated,
49077
- summary,
49078
- minLength,
49079
- maxLength,
49080
- minimum,
49081
- maximum,
49082
- exclusiveMinimum,
49083
- exclusiveMaximum,
49084
- minItems,
49085
- maxItems,
49086
- nullable,
49087
- pattern
49088
- }, tryOneLine = false) {
49094
+ function jsDoc(schema, tryOneLine = false, context) {
49095
+ if (context?.output?.override?.jsDoc) {
49096
+ const { filter: filter2 } = context.output.override.jsDoc;
49097
+ if (filter2) {
49098
+ return keyValuePairsToJsDoc(filter2(schema));
49099
+ }
49100
+ }
49101
+ const {
49102
+ description,
49103
+ deprecated,
49104
+ summary,
49105
+ minLength,
49106
+ maxLength,
49107
+ minimum,
49108
+ maximum,
49109
+ exclusiveMinimum,
49110
+ exclusiveMaximum,
49111
+ minItems,
49112
+ maxItems,
49113
+ nullable,
49114
+ pattern
49115
+ } = schema;
49089
49116
  const lines = (Array.isArray(description) ? description.filter((d2) => !d2.includes("eslint-disable")) : [description || ""]).map((line) => line.replace(regex, replacement));
49090
49117
  const count2 = [
49091
49118
  description,
@@ -49157,6 +49184,16 @@ ${tryOneLine ? " " : ""} *`;
49157
49184
  doc += "*/\n";
49158
49185
  return doc;
49159
49186
  }
49187
+ function keyValuePairsToJsDoc(keyValues) {
49188
+ if (!keyValues.length) return "";
49189
+ let doc = "/**\n";
49190
+ keyValues.forEach(({ key, value }) => {
49191
+ doc += ` * @${key} ${value}
49192
+ `;
49193
+ });
49194
+ doc += " */\n";
49195
+ return doc;
49196
+ }
49160
49197
 
49161
49198
  // src/utils/dynamic-import.ts
49162
49199
  var import_url = require("url");
@@ -49373,6 +49410,7 @@ var jsStringEscape = (input) => input.replace(/["'\\\n\r\u2028\u2029]/g, (charac
49373
49410
  case "'":
49374
49411
  case "\\":
49375
49412
  return "\\" + character;
49413
+ // Four possible LineTerminator characters need to be escaped:
49376
49414
  case "\n":
49377
49415
  return "\\n";
49378
49416
  case "\r":
@@ -49431,38 +49469,53 @@ var getIsBodyVerb = (verb) => VERBS_WITH_BODY.includes(verb);
49431
49469
  var getEnumNames = (schemaObject) => {
49432
49470
  return schemaObject?.["x-enumNames"] || schemaObject?.["x-enumnames"] || schemaObject?.["x-enum-varnames"];
49433
49471
  };
49434
- var getEnum = (value, enumName, names, enumGenerationType) => {
49472
+ var getEnumDescriptions = (schemaObject) => {
49473
+ return schemaObject?.["x-enumDescriptions"] || schemaObject?.["x-enumdescriptions"] || schemaObject?.["x-enum-descriptions"];
49474
+ };
49475
+ var getEnum = (value, enumName, names, enumGenerationType, descriptions, enumNamingConvention) => {
49435
49476
  if (enumGenerationType === EnumGeneration.CONST)
49436
- return getTypeConstEnum(value, enumName, names);
49477
+ return getTypeConstEnum(
49478
+ value,
49479
+ enumName,
49480
+ names,
49481
+ descriptions,
49482
+ enumNamingConvention
49483
+ );
49437
49484
  if (enumGenerationType === EnumGeneration.ENUM)
49438
- return getNativeEnum(value, enumName, names);
49485
+ return getNativeEnum(value, enumName, names, enumNamingConvention);
49439
49486
  if (enumGenerationType === EnumGeneration.UNION)
49440
49487
  return getUnion(value, enumName);
49441
49488
  throw new Error(`Invalid enumGenerationType: ${enumGenerationType}`);
49442
49489
  };
49443
- var getTypeConstEnum = (value, enumName, names) => {
49490
+ var getTypeConstEnum = (value, enumName, names, descriptions, enumNamingConvention) => {
49444
49491
  let enumValue = `export type ${enumName} = typeof ${enumName}[keyof typeof ${enumName}]`;
49445
49492
  if (value.endsWith(" | null")) {
49446
49493
  value = value.replace(" | null", "");
49447
49494
  enumValue += " | null";
49448
49495
  }
49449
49496
  enumValue += ";\n";
49450
- const implementation = getEnumImplementation(value, names);
49451
- enumValue += `
49452
-
49453
- `;
49497
+ const implementation = getEnumImplementation(
49498
+ value,
49499
+ names,
49500
+ descriptions,
49501
+ enumNamingConvention
49502
+ );
49503
+ enumValue += "\n\n";
49454
49504
  enumValue += "// eslint-disable-next-line @typescript-eslint/no-redeclare\n";
49455
49505
  enumValue += `export const ${enumName} = {
49456
49506
  ${implementation}} as const;
49457
49507
  `;
49458
49508
  return enumValue;
49459
49509
  };
49460
- var getEnumImplementation = (value, names) => {
49510
+ var getEnumImplementation = (value, names, descriptions, enumNamingConvention) => {
49461
49511
  if (value === "") return "";
49462
49512
  return [...new Set(value.split(" | "))].reduce((acc, val, index3) => {
49463
49513
  const name = names?.[index3];
49514
+ const description = descriptions?.[index3];
49515
+ const comment = description ? ` /** ${description} */
49516
+ ` : "";
49464
49517
  if (name) {
49465
- return acc + ` ${import_esutils2.keyword.isIdentifierNameES5(name) ? name : `'${name}'`}: ${val},
49518
+ return acc + comment + ` ${import_esutils2.keyword.isIdentifierNameES5(name) ? name : `'${name}'`}: ${val},
49466
49519
  `;
49467
49520
  }
49468
49521
  let key = val.startsWith("'") ? val.slice(1, -1) : val;
@@ -49478,18 +49531,21 @@ var getEnumImplementation = (value, names) => {
49478
49531
  special: true
49479
49532
  });
49480
49533
  }
49481
- return acc + ` ${import_esutils2.keyword.isIdentifierNameES5(key) ? key : `'${key}'`}: ${val},
49534
+ if (enumNamingConvention) {
49535
+ key = conventionName(key, enumNamingConvention);
49536
+ }
49537
+ return acc + comment + ` ${import_esutils2.keyword.isIdentifierNameES5(key) ? key : `'${key}'`}: ${val},
49482
49538
  `;
49483
49539
  }, "");
49484
49540
  };
49485
- var getNativeEnum = (value, enumName, names) => {
49486
- const enumItems = getNativeEnumItems(value, names);
49541
+ var getNativeEnum = (value, enumName, names, enumNamingConvention) => {
49542
+ const enumItems = getNativeEnumItems(value, names, enumNamingConvention);
49487
49543
  const enumValue = `export enum ${enumName} {
49488
49544
  ${enumItems}
49489
49545
  }`;
49490
49546
  return enumValue;
49491
49547
  };
49492
- var getNativeEnumItems = (value, names) => {
49548
+ var getNativeEnumItems = (value, names, enumNamingConvention) => {
49493
49549
  if (value === "") return "";
49494
49550
  return [...new Set(value.split(" | "))].reduce((acc, val, index3) => {
49495
49551
  const name = names?.[index3];
@@ -49510,6 +49566,9 @@ var getNativeEnumItems = (value, names) => {
49510
49566
  special: true
49511
49567
  });
49512
49568
  }
49569
+ if (enumNamingConvention) {
49570
+ key = conventionName(key, enumNamingConvention);
49571
+ }
49513
49572
  return acc + ` ${import_esutils2.keyword.isIdentifierNameES5(key) ? key : `'${key}'`}= ${val},
49514
49573
  `;
49515
49574
  }, "");
@@ -49767,7 +49826,9 @@ var resolveObjectOriginal = ({
49767
49826
  resolvedValue.value,
49768
49827
  propName,
49769
49828
  getEnumNames(resolvedValue.originalSchema),
49770
- context.output.override.enumGenerationType
49829
+ context.output.override.enumGenerationType,
49830
+ getEnumDescriptions(resolvedValue.originalSchema),
49831
+ context.output.override.namingConvention?.enum
49771
49832
  );
49772
49833
  return {
49773
49834
  value: propName,
@@ -50065,16 +50126,14 @@ var getFormDataAdditionalImports = ({
50065
50126
  context
50066
50127
  }) => {
50067
50128
  const { schema } = resolveRef(schemaObject, context);
50068
- if (schema.type === "object") {
50069
- if (schema.oneOf || schema.anyOf) {
50070
- const combinedSchemas = schema.oneOf || schema.anyOf;
50071
- return combinedSchemas.map((schema2) => {
50072
- const { imports } = resolveRef(schema2, context);
50073
- return imports[0];
50074
- });
50075
- }
50129
+ if (schema.type !== "object") {
50130
+ return [];
50131
+ }
50132
+ const combinedSchemas = schema.oneOf || schema.anyOf;
50133
+ if (!combinedSchemas) {
50134
+ return [];
50076
50135
  }
50077
- return [];
50136
+ return combinedSchemas.map((schema2) => resolveRef(schema2, context).imports[0]).filter(Boolean);
50078
50137
  };
50079
50138
  var getSchemaFormDataAndUrlEncoded = ({
50080
50139
  name,
@@ -50163,6 +50222,9 @@ var resolveSchemaPropertiesToFormData = ({
50163
50222
  const formDataValues = Object.entries(schema.properties ?? {}).reduce(
50164
50223
  (acc, [key, value]) => {
50165
50224
  const { schema: property } = resolveRef(value, context);
50225
+ if (property.readOnly) {
50226
+ return acc;
50227
+ }
50166
50228
  let formDataValue = "";
50167
50229
  const formattedKeyPrefix = !isRequestBodyOptional ? "" : !import_esutils3.keyword.isIdentifierNameES5(key) ? "?." : "?";
50168
50230
  const formattedKey = !import_esutils3.keyword.isIdentifierNameES5(key) ? `['${key}']` : `.${key}`;
@@ -50345,6 +50407,51 @@ var getKey = (key) => {
50345
50407
  return import_esutils4.keyword.isIdentifierNameES5(key) ? key : `'${key}'`;
50346
50408
  };
50347
50409
 
50410
+ // src/getters/imports.ts
50411
+ var getAliasedImports = ({
50412
+ name,
50413
+ resolvedValue,
50414
+ existingImports,
50415
+ context
50416
+ }) => context.output.schemas && resolvedValue.isRef ? resolvedValue.imports.map((imp) => {
50417
+ if (!needCreateImportAlias({
50418
+ name,
50419
+ imp,
50420
+ existingImports
50421
+ })) {
50422
+ return imp;
50423
+ }
50424
+ const specName = pascal(
50425
+ getSpecName(imp.specKey ?? "", context.specKey)
50426
+ );
50427
+ const normalizedSpecName = /^\d/.test(specName) ? `__${specName}` : specName;
50428
+ return {
50429
+ ...imp,
50430
+ alias: `${normalizedSpecName}__${imp.name}`
50431
+ };
50432
+ }) : resolvedValue.imports;
50433
+ var needCreateImportAlias = ({
50434
+ existingImports,
50435
+ imp,
50436
+ name
50437
+ }) => !imp.alias && // !!imp.specKey &&
50438
+ (imp.name === name || existingImports.some(
50439
+ (existingImport) => imp.name === existingImport.name && imp.specKey !== existingImport.specKey
50440
+ ));
50441
+ var getImportAliasForRefOrValue = ({
50442
+ context,
50443
+ imports,
50444
+ resolvedValue
50445
+ }) => {
50446
+ if (!context.output.schemas || !resolvedValue.isRef) {
50447
+ return resolvedValue.value;
50448
+ }
50449
+ const importWithSameName = imports.find(
50450
+ (imp) => imp.name === resolvedValue.value
50451
+ );
50452
+ return importWithSameName?.alias ?? resolvedValue.value;
50453
+ };
50454
+
50348
50455
  // src/getters/object.ts
50349
50456
  var getObject = ({
50350
50457
  item,
@@ -50376,7 +50483,7 @@ var getObject = ({
50376
50483
  nullable
50377
50484
  });
50378
50485
  }
50379
- if (item.type instanceof Array) {
50486
+ if (Array.isArray(item.type)) {
50380
50487
  return combineSchemas({
50381
50488
  schema: {
50382
50489
  anyOf: item.type.map((type) => ({
@@ -50423,11 +50530,22 @@ var getObject = ({
50423
50530
  if (!index3) {
50424
50531
  acc.value += "{";
50425
50532
  }
50426
- const doc = jsDoc(schema, true);
50533
+ const doc = jsDoc(schema, true, context);
50427
50534
  acc.hasReadonlyProps ||= isReadOnly || false;
50428
- acc.imports.push(...resolvedValue.imports);
50535
+ const aliasedImports = getAliasedImports({
50536
+ name,
50537
+ context,
50538
+ resolvedValue,
50539
+ existingImports: acc.imports
50540
+ });
50541
+ acc.imports.push(...aliasedImports);
50542
+ const propValue = getImportAliasForRefOrValue({
50543
+ context,
50544
+ resolvedValue,
50545
+ imports: aliasedImports
50546
+ });
50429
50547
  acc.value += `
50430
- ${doc ? `${doc} ` : ""}${isReadOnly && !context.output.override.suppressReadonlyModifier ? "readonly " : ""}${getKey(key)}${isRequired ? "" : "?"}: ${resolvedValue.value};`;
50548
+ ${doc ? `${doc} ` : ""}${isReadOnly && !context.output.override.suppressReadonlyModifier ? "readonly " : ""}${getKey(key)}${isRequired ? "" : "?"}: ${propValue};`;
50431
50549
  acc.schemas.push(...resolvedValue.schemas);
50432
50550
  if (arr.length - 1 === index3) {
50433
50551
  if (item.additionalProperties) {
@@ -50522,8 +50640,7 @@ var getScalar = ({
50522
50640
  name,
50523
50641
  context
50524
50642
  }) => {
50525
- const isAngularClient = context.output.client === OutputClient.ANGULAR;
50526
- const nullable = item.nullable && !isAngularClient ? " | null" : "";
50643
+ const nullable = item.nullable ? " | null" : "";
50527
50644
  const enumItems = item.enum?.filter((enumItem) => enumItem !== null);
50528
50645
  if (!item.type && item.items) {
50529
50646
  item.type = "array";
@@ -50748,8 +50865,19 @@ var combineSchemas = ({
50748
50865
  combined: true,
50749
50866
  context
50750
50867
  });
50751
- acc.values.push(resolvedValue2.value);
50752
- acc.imports.push(...resolvedValue2.imports);
50868
+ const aliasedImports = getAliasedImports({
50869
+ context,
50870
+ name,
50871
+ resolvedValue: resolvedValue2,
50872
+ existingImports: acc.imports
50873
+ });
50874
+ const value2 = getImportAliasForRefOrValue({
50875
+ context,
50876
+ resolvedValue: resolvedValue2,
50877
+ imports: aliasedImports
50878
+ });
50879
+ acc.values.push(value2);
50880
+ acc.imports.push(...aliasedImports);
50753
50881
  acc.schemas.push(...resolvedValue2.schemas);
50754
50882
  acc.isEnum.push(resolvedValue2.isEnum);
50755
50883
  acc.types.push(resolvedValue2.type);
@@ -50857,7 +50985,8 @@ var getCombineEnumValue = ({
50857
50985
  return `...${e3},`;
50858
50986
  }
50859
50987
  const names = getEnumNames(originalSchema[i3]);
50860
- return getEnumImplementation(e3, names);
50988
+ const descriptions = getEnumDescriptions(originalSchema[i3]);
50989
+ return getEnumImplementation(e3, names, descriptions);
50861
50990
  }).join("");
50862
50991
  return `{${enums}} as const`;
50863
50992
  };
@@ -51044,10 +51173,10 @@ var getProps = ({
51044
51173
  };
51045
51174
  const queryParamsProp = {
51046
51175
  name: "params",
51047
- definition: `params${queryParams?.isOptional ? "?" : ""}: ${queryParams?.schema.name}`,
51048
- implementation: `params${queryParams?.isOptional ? "?" : ""}: ${queryParams?.schema.name}`,
51176
+ definition: getQueryParamDefinition(queryParams, context),
51177
+ implementation: getQueryParamDefinition(queryParams, context),
51049
51178
  default: false,
51050
- required: !isUndefined(queryParams?.isOptional) ? !queryParams?.isOptional : false,
51179
+ required: !isUndefined(queryParams?.isOptional) ? !queryParams?.isOptional && !context.output.allParamsOptional : !context.output.allParamsOptional,
51051
51180
  type: GetterPropType.QUERY_PARAM
51052
51181
  };
51053
51182
  const headersProp = {
@@ -51101,6 +51230,13 @@ var getProps = ({
51101
51230
  const sortedProps = sortByPriority(props);
51102
51231
  return sortedProps;
51103
51232
  };
51233
+ function getQueryParamDefinition(queryParams, context) {
51234
+ let paramType = queryParams?.schema.name;
51235
+ if (OutputClient.ANGULAR === context.output.client) {
51236
+ paramType = `DeepNonNullable<${paramType}>`;
51237
+ }
51238
+ return `params${queryParams?.isOptional || context.output.allParamsOptional ? "?" : ""}: ${paramType}`;
51239
+ }
51104
51240
 
51105
51241
  // src/getters/query-params.ts
51106
51242
  var getQueryParamsTypes = (queryParams, operationName, context) => {
@@ -51125,7 +51261,14 @@ var getQueryParamsTypes = (queryParams, operationName, context) => {
51125
51261
  name: queryName
51126
51262
  });
51127
51263
  const key = getKey(name);
51128
- const doc = jsDoc(parameter);
51264
+ const doc = jsDoc(
51265
+ {
51266
+ description: parameter.description,
51267
+ ...schema
51268
+ },
51269
+ void 0,
51270
+ context
51271
+ );
51129
51272
  if (parameterImports.length) {
51130
51273
  return {
51131
51274
  definition: `${doc}${key}${!required || schema.default ? "?" : ""}: ${parameterImports[0].name};`,
@@ -51140,7 +51283,9 @@ var getQueryParamsTypes = (queryParams, operationName, context) => {
51140
51283
  resolvedValue.value,
51141
51284
  enumName,
51142
51285
  getEnumNames(resolvedValue.originalSchema),
51143
- context.output.override.enumGenerationType
51286
+ context.output.override.enumGenerationType,
51287
+ getEnumDescriptions(resolvedValue.originalSchema),
51288
+ context.output.override.namingConvention?.enum
51144
51289
  );
51145
51290
  return {
51146
51291
  definition: `${doc}${key}${!required || schema.default ? "?" : ""}: ${enumName};`,
@@ -51215,8 +51360,8 @@ var getResponse = ({
51215
51360
  Object.entries(responses),
51216
51361
  operationName,
51217
51362
  context,
51218
- "void",
51219
- (type) => type.key.startsWith("2") + type.value
51363
+ "null",
51364
+ (type) => `${type.key}-${type.value}`
51220
51365
  );
51221
51366
  const filteredTypes = contentType ? types.filter((type) => {
51222
51367
  let include = true;
@@ -51839,7 +51984,7 @@ var generateAxiosOptions = ({
51839
51984
  paramsSerializerOptions
51840
51985
  }) => {
51841
51986
  const isRequestOptions = requestOptions !== false;
51842
- if (!queryParams && !headers && !response.isBlob) {
51987
+ if (!queryParams && !headers && !response.isBlob && response.definition.success !== "string") {
51843
51988
  if (isRequestOptions) {
51844
51989
  return "options";
51845
51990
  }
@@ -51860,9 +52005,14 @@ var generateAxiosOptions = ({
51860
52005
  value += !isExactOptionalPropertyTypes ? "\n signal," : "\n ...(signal ? { signal } : {}),";
51861
52006
  }
51862
52007
  }
51863
- if (response.isBlob && (!isObject(requestOptions) || !requestOptions.hasOwnProperty("responseType"))) {
51864
- value += `
52008
+ if (!isObject(requestOptions) || !requestOptions.hasOwnProperty("responseType")) {
52009
+ if (response.isBlob) {
52010
+ value += `
51865
52011
  responseType: 'blob',`;
52012
+ } else if (response.definition.success === "string") {
52013
+ value += `
52014
+ responseType: 'text',`;
52015
+ }
51866
52016
  }
51867
52017
  if (isObject(requestOptions)) {
51868
52018
  value += `
@@ -52106,7 +52256,7 @@ var generateInterface = ({
52106
52256
  }
52107
52257
  if (scalar.type === "object" && !context?.output.override?.useTypeOverInterfaces) {
52108
52258
  if (scalar.type === "object" && schema.properties && Object.values(schema.properties).length > 0 && Object.values(schema.properties).every((item) => "const" in item)) {
52109
- const mappedScalarValue = scalar.value.replaceAll(";", ",");
52259
+ const mappedScalarValue = scalar.value.replaceAll(";", ",").replaceAll("?:", ":");
52110
52260
  model += `export const ${name}Value = ${mappedScalarValue} as const;
52111
52261
  export type ${name} = typeof ${name}Value;
52112
52262
  `;
@@ -52120,7 +52270,7 @@ export type ${name} = typeof ${name}Value;
52120
52270
  `;
52121
52271
  }
52122
52272
  const externalModulesImportsOnly = scalar.imports.filter(
52123
- (importName) => importName.name !== name
52273
+ (importName) => importName.alias ? importName.alias !== name : importName.name !== name
52124
52274
  );
52125
52275
  return [
52126
52276
  ...scalar.schemas,
@@ -52181,7 +52331,9 @@ var generateSchemasDefinition = (schemas = {}, context, suffix, filters) => {
52181
52331
  resolvedValue.value,
52182
52332
  schemaName,
52183
52333
  getEnumNames(resolvedValue.originalSchema),
52184
- context.output.override.enumGenerationType
52334
+ context.output.override.enumGenerationType,
52335
+ getEnumDescriptions(resolvedValue.originalSchema),
52336
+ context.output.override.namingConvention?.enum
52185
52337
  );
52186
52338
  } else if (schemaName === resolvedValue.value && resolvedValue.isRef) {
52187
52339
  const { schema: referredSchema } = resolveRef(schema, context);
@@ -52329,6 +52481,13 @@ var generateVerbOptions = async ({
52329
52481
  workspace: context.workspace,
52330
52482
  tsconfig: context.output.tsconfig
52331
52483
  }) : void 0;
52484
+ const fetchReviver = isString2(override?.fetch.jsonReviver) || isObject(override?.fetch.jsonReviver) ? await generateMutator({
52485
+ output: output.target,
52486
+ name: "fetchReviver",
52487
+ mutator: override.fetch.jsonReviver,
52488
+ workspace: context.workspace,
52489
+ tsconfig: context.output.tsconfig
52490
+ }) : void 0;
52332
52491
  const doc = jsDoc({ description, deprecated, summary });
52333
52492
  const verbOption = {
52334
52493
  verb,
@@ -52348,6 +52507,7 @@ var generateVerbOptions = async ({
52348
52507
  formData,
52349
52508
  formUrlEncoded,
52350
52509
  paramsSerializer,
52510
+ fetchReviver,
52351
52511
  override,
52352
52512
  doc,
52353
52513
  deprecated,
@@ -52559,6 +52719,11 @@ type NonReadonly<T> = [T] extends [UnionToIntersection<T>] ? {
52559
52719
  : T[P];
52560
52720
  } : DistributeReadOnlyOverUnions<T>;
52561
52721
  `;
52722
+ var getTypedResponse = () => `
52723
+ interface TypedResponse<T> extends Response {
52724
+ json(): Promise<T>;
52725
+ }
52726
+ `;
52562
52727
 
52563
52728
  // src/writers/single-mode.ts
52564
52729
  var import_fs_extra3 = __toESM(require("fs-extra"));
@@ -52606,6 +52771,9 @@ var generateTarget = (builder, options) => {
52606
52771
  if (operation.clientMutators) {
52607
52772
  acc.clientMutators.push(...operation.clientMutators);
52608
52773
  }
52774
+ if (operation.fetchReviver) {
52775
+ acc.fetchReviver.push(operation.fetchReviver);
52776
+ }
52609
52777
  if (index3 === arr.length - 1) {
52610
52778
  const isMutator = acc.mutators.some(
52611
52779
  (mutator) => isAngularClient ? mutator.hasThirdArg : mutator.hasSecondArg
@@ -52652,7 +52820,8 @@ var generateTarget = (builder, options) => {
52652
52820
  clientMutators: [],
52653
52821
  formData: [],
52654
52822
  formUrlEncoded: [],
52655
- paramsSerializer: []
52823
+ paramsSerializer: [],
52824
+ fetchReviver: []
52656
52825
  }
52657
52826
  );
52658
52827
  return {
@@ -52686,7 +52855,8 @@ var writeSingleMode = async ({
52686
52855
  clientMutators,
52687
52856
  formData,
52688
52857
  formUrlEncoded,
52689
- paramsSerializer
52858
+ paramsSerializer,
52859
+ fetchReviver
52690
52860
  } = generateTarget(builder, output);
52691
52861
  let data = header;
52692
52862
  const schemasPath = output.schemas ? path_exports.relativeSafe(
@@ -52744,10 +52914,17 @@ var writeSingleMode = async ({
52744
52914
  if (paramsSerializer) {
52745
52915
  data += generateMutatorImports({ mutators: paramsSerializer });
52746
52916
  }
52917
+ if (fetchReviver) {
52918
+ data += generateMutatorImports({ mutators: fetchReviver });
52919
+ }
52747
52920
  if (implementation.includes("NonReadonly<")) {
52748
52921
  data += getOrvalGeneratedTypes();
52749
52922
  data += "\n";
52750
52923
  }
52924
+ if (implementation.includes("TypedResponse<")) {
52925
+ data += getTypedResponse();
52926
+ data += "\n";
52927
+ }
52751
52928
  if (!output.schemas && needSchema) {
52752
52929
  data += generateModelsInline(builder.schemas);
52753
52930
  }
@@ -52790,7 +52967,8 @@ var writeSplitMode = async ({
52790
52967
  clientMutators,
52791
52968
  formData,
52792
52969
  formUrlEncoded,
52793
- paramsSerializer
52970
+ paramsSerializer,
52971
+ fetchReviver
52794
52972
  } = generateTarget(builder, output);
52795
52973
  let implementationData = header;
52796
52974
  let mockData = header;
@@ -52866,8 +53044,18 @@ var writeSplitMode = async ({
52866
53044
  mutators: paramsSerializer
52867
53045
  });
52868
53046
  }
53047
+ if (fetchReviver) {
53048
+ implementationData += generateMutatorImports({
53049
+ mutators: fetchReviver
53050
+ });
53051
+ }
52869
53052
  if (implementation.includes("NonReadonly<")) {
52870
53053
  implementationData += getOrvalGeneratedTypes();
53054
+ implementationData += "\n";
53055
+ }
53056
+ if (implementation.includes("TypedResponse<")) {
53057
+ implementationData += getTypedResponse();
53058
+ implementationData += "\n";
52871
53059
  }
52872
53060
  implementationData += `
52873
53061
  ${implementation}`;
@@ -52916,6 +53104,7 @@ var generateTargetTags = (currentAcc, operation) => {
52916
53104
  formData: operation.formData ? [operation.formData] : [],
52917
53105
  formUrlEncoded: operation.formUrlEncoded ? [operation.formUrlEncoded] : [],
52918
53106
  paramsSerializer: operation.paramsSerializer ? [operation.paramsSerializer] : [],
53107
+ fetchReviver: operation.fetchReviver ? [operation.fetchReviver] : [],
52919
53108
  implementation: operation.implementation,
52920
53109
  implementationMock: {
52921
53110
  function: operation.implementationMock.function,
@@ -52944,7 +53133,8 @@ var generateTargetTags = (currentAcc, operation) => {
52944
53133
  paramsSerializer: operation.paramsSerializer ? [
52945
53134
  ...currentOperation.paramsSerializer ?? [],
52946
53135
  operation.paramsSerializer
52947
- ] : currentOperation.paramsSerializer
53136
+ ] : currentOperation.paramsSerializer,
53137
+ fetchReviver: operation.fetchReviver ? [...currentOperation.fetchReviver ?? [], operation.fetchReviver] : currentOperation.fetchReviver
52948
53138
  };
52949
53139
  return currentAcc;
52950
53140
  };
@@ -53001,7 +53191,8 @@ var generateTargetForTags = (builder, options) => {
53001
53191
  clientMutators: target.clientMutators,
53002
53192
  formData: target.formData,
53003
53193
  formUrlEncoded: target.formUrlEncoded,
53004
- paramsSerializer: target.paramsSerializer
53194
+ paramsSerializer: target.paramsSerializer,
53195
+ fetchReviver: target.fetchReviver
53005
53196
  };
53006
53197
  return acc2;
53007
53198
  }, {});
@@ -53056,6 +53247,7 @@ var writeSplitTagsMode = async ({
53056
53247
  mutators,
53057
53248
  clientMutators,
53058
53249
  formData,
53250
+ fetchReviver,
53059
53251
  formUrlEncoded,
53060
53252
  paramsSerializer
53061
53253
  } = target2;
@@ -53134,10 +53326,20 @@ var writeSplitTagsMode = async ({
53134
53326
  oneMore: true
53135
53327
  });
53136
53328
  }
53329
+ if (fetchReviver) {
53330
+ implementationData += generateMutatorImports({
53331
+ mutators: fetchReviver,
53332
+ oneMore: true
53333
+ });
53334
+ }
53137
53335
  if (implementation.includes("NonReadonly<")) {
53138
53336
  implementationData += getOrvalGeneratedTypes();
53139
53337
  implementationData += "\n";
53140
53338
  }
53339
+ if (implementation.includes("TypedResponse<")) {
53340
+ implementationData += getTypedResponse();
53341
+ implementationData += "\n";
53342
+ }
53141
53343
  implementationData += `
53142
53344
  ${implementation}`;
53143
53345
  mockData += `
@@ -53208,6 +53410,7 @@ var writeTagsMode = async ({
53208
53410
  clientMutators,
53209
53411
  formData,
53210
53412
  formUrlEncoded,
53413
+ fetchReviver,
53211
53414
  paramsSerializer
53212
53415
  } = target2;
53213
53416
  let data = header;
@@ -53274,11 +53477,18 @@ var writeTagsMode = async ({
53274
53477
  if (paramsSerializer) {
53275
53478
  data += generateMutatorImports({ mutators: paramsSerializer });
53276
53479
  }
53480
+ if (fetchReviver) {
53481
+ data += generateMutatorImports({ mutators: fetchReviver });
53482
+ }
53277
53483
  data += "\n\n";
53278
53484
  if (implementation.includes("NonReadonly<")) {
53279
53485
  data += getOrvalGeneratedTypes();
53280
53486
  data += "\n";
53281
53487
  }
53488
+ if (implementation.includes("TypedResponse<")) {
53489
+ data += getTypedResponse();
53490
+ data += "\n";
53491
+ }
53282
53492
  data += implementation;
53283
53493
  if (output.mock) {
53284
53494
  data += "\n\n";
@@ -53355,6 +53565,7 @@ var writeTagsMode = async ({
53355
53565
  getArray,
53356
53566
  getBody,
53357
53567
  getEnum,
53568
+ getEnumDescriptions,
53358
53569
  getEnumImplementation,
53359
53570
  getEnumNames,
53360
53571
  getExtension,
@@ -53378,6 +53589,7 @@ var writeTagsMode = async ({
53378
53589
  getRoute,
53379
53590
  getRouteAsArray,
53380
53591
  getScalar,
53592
+ getTypedResponse,
53381
53593
  ibmOpenapiValidator,
53382
53594
  ibmOpenapiValidatorErrors,
53383
53595
  ibmOpenapiValidatorWarnings,
@@ -53400,6 +53612,7 @@ var writeTagsMode = async ({
53400
53612
  jsDoc,
53401
53613
  jsStringEscape,
53402
53614
  kebab,
53615
+ keyValuePairsToJsDoc,
53403
53616
  loadFile,
53404
53617
  log,
53405
53618
  logError,