swagger-typescript-api 13.2.10 → 13.2.11

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.
@@ -5,11 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
8
+ var __export = (all) => {
9
+ let target = {};
9
10
  for (var name$1 in all) __defProp(target, name$1, {
10
11
  get: all[name$1],
11
12
  enumerable: true
12
13
  });
14
+ return target;
13
15
  };
14
16
  var __copyProps = (to, from, except, desc) => {
15
17
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
@@ -27,18 +29,30 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
29
  }) : target, mod));
28
30
 
29
31
  //#endregion
30
- const consola = __toESM(require("consola"));
31
- const lodash = __toESM(require("lodash"));
32
- const typescript = __toESM(require("typescript"));
33
- const node_path = __toESM(require("node:path"));
34
- const __biomejs_js_api = __toESM(require("@biomejs/js-api"));
35
- const nanoid = __toESM(require("nanoid"));
36
- const js_yaml = __toESM(require("js-yaml"));
37
- const swagger2openapi = __toESM(require("swagger2openapi"));
38
- const node_module = __toESM(require("node:module"));
39
- const node_url = __toESM(require("node:url"));
40
- const eta = __toESM(require("eta"));
41
- const node_fs = __toESM(require("node:fs"));
32
+ let consola = require("consola");
33
+ consola = __toESM(consola);
34
+ let lodash = require("lodash");
35
+ lodash = __toESM(lodash);
36
+ let typescript = require("typescript");
37
+ typescript = __toESM(typescript);
38
+ let node_path = require("node:path");
39
+ node_path = __toESM(node_path);
40
+ let __biomejs_js_api = require("@biomejs/js-api");
41
+ __biomejs_js_api = __toESM(__biomejs_js_api);
42
+ let nanoid = require("nanoid");
43
+ nanoid = __toESM(nanoid);
44
+ let js_yaml = require("js-yaml");
45
+ js_yaml = __toESM(js_yaml);
46
+ let swagger2openapi = require("swagger2openapi");
47
+ swagger2openapi = __toESM(swagger2openapi);
48
+ let node_module = require("node:module");
49
+ node_module = __toESM(node_module);
50
+ let node_url = require("node:url");
51
+ node_url = __toESM(node_url);
52
+ let eta = require("eta");
53
+ eta = __toESM(eta);
54
+ let node_fs = require("node:fs");
55
+ node_fs = __toESM(node_fs);
42
56
 
43
57
  //#region src/code-formatter.ts
44
58
  var CodeFormatter = class {
@@ -49,8 +63,7 @@ var CodeFormatter = class {
49
63
  removeUnusedImports = (content) => {
50
64
  const tempFileName = "file.ts";
51
65
  const host = new TsLanguageServiceHost(tempFileName, content);
52
- const languageService = typescript.createLanguageService(host);
53
- const fileTextChanges = languageService.organizeImports({
66
+ const fileTextChanges = typescript.createLanguageService(host).organizeImports({
54
67
  type: "file",
55
68
  fileName: tempFileName
56
69
  }, { newLineCharacter: typescript.sys.newLine }, void 0)[0];
@@ -64,11 +77,10 @@ var CodeFormatter = class {
64
77
  files: { maxSize: Number.MAX_SAFE_INTEGER },
65
78
  formatter: { indentStyle: "space" }
66
79
  });
67
- const formatted = biome.formatContent(biomeProject.projectKey, content, { filePath: node_path.format({
80
+ return biome.formatContent(biomeProject.projectKey, content, { filePath: node_path.format({
68
81
  name: nanoid.nanoid(),
69
82
  ext: "ts"
70
- }) });
71
- return formatted.content;
83
+ }) }).content;
72
84
  };
73
85
  formatCode = async (code, { removeUnusedImports = true, format = true } = {}) => {
74
86
  if (removeUnusedImports) code = this.removeUnusedImports(code);
@@ -204,7 +216,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
204
216
  //#endregion
205
217
  //#region package.json
206
218
  var name = "swagger-typescript-api";
207
- var version = "13.2.10";
219
+ var version = "13.2.11";
208
220
  var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
209
221
  var homepage = "https://github.com/acacode/swagger-typescript-api";
210
222
  var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
@@ -247,10 +259,10 @@ var dependencies = {
247
259
  "@biomejs/js-api": "3.0.0",
248
260
  "@biomejs/wasm-nodejs": "2.2.4",
249
261
  "@types/swagger-schema-official": "^2.0.25",
250
- "c12": "^3.2.0",
262
+ "c12": "^3.3.0",
251
263
  "citty": "^0.1.6",
252
264
  "consola": "^3.4.2",
253
- "eta": "^2.2.0",
265
+ "eta": "^4.0.1",
254
266
  "js-yaml": "^4.1.0",
255
267
  "lodash": "^4.17.21",
256
268
  "nanoid": "^5.1.5",
@@ -266,12 +278,12 @@ var devDependencies = {
266
278
  "@tsconfig/strictest": "2.0.5",
267
279
  "@types/js-yaml": "4.0.9",
268
280
  "@types/lodash": "4.17.20",
269
- "@types/node": "24.3.2",
281
+ "@types/node": "24.5.2",
270
282
  "@types/swagger2openapi": "7.0.4",
271
- "axios": "1.12.1",
283
+ "axios": "1.12.2",
272
284
  "openapi-types": "12.1.3",
273
- "tsdown": "0.15.1",
274
- "typedoc": "0.28.12",
285
+ "tsdown": "0.15.2",
286
+ "typedoc": "0.28.13",
275
287
  "vitest": "3.2.4"
276
288
  };
277
289
  var packageManager = "yarn@4.9.4";
@@ -313,8 +325,7 @@ var package_default = {
313
325
 
314
326
  //#endregion
315
327
  //#region src/constants.ts
316
- var constants_exports = {};
317
- __export(constants_exports, {
328
+ var constants_exports = /* @__PURE__ */ __export({
318
329
  DEFAULT_BODY_ARG_NAME: () => DEFAULT_BODY_ARG_NAME,
319
330
  FILE_PREFIX: () => FILE_PREFIX,
320
331
  HTTP_CLIENT: () => HTTP_CLIENT,
@@ -764,9 +775,9 @@ var SchemaComponentsMap = class {
764
775
  filter(...componentNames) {
765
776
  return this._data.filter((it) => componentNames.some((componentName) => it.$ref.startsWith(`#/components/${componentName}`)));
766
777
  }
767
- get($ref) {
778
+ get = ($ref) => {
768
779
  return this._data.find((c) => c.$ref === $ref) || null;
769
- }
780
+ };
770
781
  enumsFirst() {
771
782
  this._data.sort((a, b) => {
772
783
  if (Object.keys(a.rawTypeData || {}).includes("enum")) return -1;
@@ -774,6 +785,13 @@ var SchemaComponentsMap = class {
774
785
  return 0;
775
786
  });
776
787
  }
788
+ discriminatorsFirst() {
789
+ this._data.sort((a, b) => {
790
+ if (Object.keys(a.rawTypeData || {}).includes("discriminator")) return -1;
791
+ if (Object.keys(b.rawTypeData || {}).includes("discriminator")) return 1;
792
+ return 0;
793
+ });
794
+ }
777
795
  };
778
796
 
779
797
  //#endregion
@@ -837,13 +855,11 @@ var SchemaFormatters = class {
837
855
  };
838
856
  formatSchema = (parsedSchema, formatType = "base") => {
839
857
  const schemaType = lodash.default.get(parsedSchema, ["schemaType"]) || lodash.default.get(parsedSchema, ["$parsed", "schemaType"]);
840
- const formatterFn = lodash.default.get(this, [formatType, schemaType]);
841
- return formatterFn?.(parsedSchema) || parsedSchema;
858
+ return lodash.default.get(this, [formatType, schemaType])?.(parsedSchema) || parsedSchema;
842
859
  };
843
860
  formatDescription = (description$1, inline) => {
844
861
  if (!description$1) return "";
845
- const hasMultipleLines = description$1.includes("\n");
846
- if (!hasMultipleLines) return description$1;
862
+ if (!description$1.includes("\n")) return description$1;
847
863
  if (inline) return lodash.default._(description$1).split(/\n/g).map((part) => part.trim()).compact().join(" ").valueOf();
848
864
  return description$1.replace(/\n$/g, "");
849
865
  };
@@ -852,8 +868,7 @@ var SchemaFormatters = class {
852
868
  for (const part of content) {
853
869
  const extraSpace = " ";
854
870
  const result = `${extraSpace}${part.field},\n`;
855
- const renderedJsDoc = this.templatesWorker.renderTemplate(this.config.templatesToRender.dataContractJsDoc, { data: part });
856
- const routeNameFromTemplate = renderedJsDoc.split("\n").map((c) => `${extraSpace}${c}`).join("\n");
871
+ const routeNameFromTemplate = this.templatesWorker.renderTemplate(this.config.templatesToRender.dataContractJsDoc, { data: part }).split("\n").map((c) => `${extraSpace}${c}`).join("\n");
857
872
  if (routeNameFromTemplate) fields.push(`${routeNameFromTemplate}${result}`);
858
873
  else fields.push(`${result}`);
859
874
  }
@@ -1013,7 +1028,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
1013
1028
  suffixes: this.config.extractingOptions.discriminatorMappingSuffix,
1014
1029
  resolver: this.config.extractingOptions.discriminatorMappingNameResolver
1015
1030
  });
1016
- const content$1 = ts.IntersectionType([ts.ObjectWrapper(ts.TypeField({
1031
+ const content = ts.IntersectionType([ts.ObjectWrapper(ts.TypeField({
1017
1032
  key: ts.StringValue(discriminator.propertyName),
1018
1033
  value: "Key"
1019
1034
  })), "Type"]);
@@ -1026,21 +1041,21 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
1026
1041
  internal: true
1027
1042
  }
1028
1043
  });
1029
- component.typeData.content = content$1;
1044
+ component.typeData.content = content;
1030
1045
  mappingTypeName = this.typeNameFormatter.format(component.typeName);
1031
1046
  }
1032
1047
  /** returns (GenericType<"mapping_key", MappingType>) or ({ discriminatorProperty: "mapping_key" } & MappingType) */
1033
1048
  const createMappingContent = (mappingSchema, mappingKey) => {
1034
- const content$1 = this.schemaParserFabric.createSchemaParser({
1049
+ const content = this.schemaParserFabric.createSchemaParser({
1035
1050
  schema: mappingSchema,
1036
1051
  schemaPath: this.schemaPath
1037
1052
  }).getInlineParseContent();
1038
1053
  const mappingUsageKey = mappingPropertySchemaEnumKeysMap[mappingKey] || ts.StringValue(mappingKey);
1039
- if (ableToCreateMappingType) return ts.TypeWithGeneric(mappingTypeName, [mappingUsageKey, content$1]);
1054
+ if (ableToCreateMappingType) return ts.TypeWithGeneric(mappingTypeName, [mappingUsageKey, content]);
1040
1055
  return ts.ExpressionGroup(ts.IntersectionType([ts.ObjectWrapper(ts.TypeField({
1041
1056
  key: discriminator.propertyName,
1042
1057
  value: mappingUsageKey
1043
- })), content$1]));
1058
+ })), content]));
1044
1059
  };
1045
1060
  for (const [mappingKey, schema] of mappingEntries) {
1046
1061
  const mappingSchema = typeof schema === "string" ? { $ref: schema } : schema;
@@ -1054,8 +1069,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
1054
1069
  mappingContents.push(createMappingContent(mappingSchema, mappingKey));
1055
1070
  }
1056
1071
  if (skipMappingType) return null;
1057
- const content = ts.ExpressionGroup(ts.UnionType(mappingContents));
1058
- return { content };
1072
+ return { content: ts.ExpressionGroup(ts.UnionType(mappingContents)) };
1059
1073
  };
1060
1074
  createMappingPropertySchemaEnumKeys = ({ abstractSchemaStruct, discPropertyName }) => {
1061
1075
  const ts = this.config.Ts;
@@ -1093,8 +1107,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
1093
1107
  const complexSchemaKeys = lodash.default.keys(this.schemaParser._complexSchemaParsers);
1094
1108
  const schema = lodash.default.omit(structuredClone(noDiscriminatorSchema), complexSchemaKeys);
1095
1109
  const schemaIsAny = this.schemaParserFabric.getInlineParseContent(structuredClone(schema)) === this.config.Ts.Keyword.Any;
1096
- const schemaIsEmpty = !lodash.default.keys(schema).length;
1097
- if (schemaIsEmpty || schemaIsAny) return null;
1110
+ if (!lodash.default.keys(schema).length || schemaIsAny) return null;
1098
1111
  const typeName = this.schemaUtils.resolveTypeName(this.typeName, {
1099
1112
  prefixes: this.config.extractingOptions.discriminatorAbstractPrefix,
1100
1113
  resolver: this.config.extractingOptions.discriminatorAbstractResolver
@@ -1423,56 +1436,36 @@ var SchemaParser = class {
1423
1436
  }
1424
1437
  _complexSchemaParsers = {
1425
1438
  [SCHEMA_TYPES$1.COMPLEX_ONE_OF]: (schema) => {
1426
- const SchemaParser$1 = this.config.schemaParsers.complexOneOf || OneOfSchemaParser;
1427
- const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
1428
- return schemaParser.parse();
1439
+ return new (this.config.schemaParsers.complexOneOf || OneOfSchemaParser)(this, schema, null, this.schemaPath).parse();
1429
1440
  },
1430
1441
  [SCHEMA_TYPES$1.COMPLEX_ALL_OF]: (schema) => {
1431
- const SchemaParser$1 = this.config.schemaParsers.complexAllOf || AllOfSchemaParser;
1432
- const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
1433
- return schemaParser.parse();
1442
+ return new (this.config.schemaParsers.complexAllOf || AllOfSchemaParser)(this, schema, null, this.schemaPath).parse();
1434
1443
  },
1435
1444
  [SCHEMA_TYPES$1.COMPLEX_ANY_OF]: (schema) => {
1436
- const SchemaParser$1 = this.config.schemaParsers.complexAnyOf || AnyOfSchemaParser;
1437
- const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
1438
- return schemaParser.parse();
1445
+ return new (this.config.schemaParsers.complexAnyOf || AnyOfSchemaParser)(this, schema, null, this.schemaPath).parse();
1439
1446
  },
1440
1447
  [SCHEMA_TYPES$1.COMPLEX_NOT]: (schema) => {
1441
- const SchemaParser$1 = this.config.schemaParsers.complexNot || NotSchemaParser;
1442
- const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
1443
- return schemaParser.parse();
1448
+ return new (this.config.schemaParsers.complexNot || NotSchemaParser)(this, schema, null, this.schemaPath).parse();
1444
1449
  }
1445
1450
  };
1446
1451
  _baseSchemaParsers = {
1447
1452
  [SCHEMA_TYPES$1.ENUM]: (schema, typeName) => {
1448
- const SchemaParser$1 = this.config.schemaParsers.enum || EnumSchemaParser;
1449
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1450
- return schemaParser.parse();
1453
+ return new (this.config.schemaParsers.enum || EnumSchemaParser)(this, schema, typeName, this.schemaPath).parse();
1451
1454
  },
1452
1455
  [SCHEMA_TYPES$1.OBJECT]: (schema, typeName) => {
1453
- const SchemaParser$1 = this.config.schemaParsers.object || ObjectSchemaParser;
1454
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1455
- return schemaParser.parse();
1456
+ return new (this.config.schemaParsers.object || ObjectSchemaParser)(this, schema, typeName, this.schemaPath).parse();
1456
1457
  },
1457
1458
  [SCHEMA_TYPES$1.COMPLEX]: (schema, typeName) => {
1458
- const SchemaParser$1 = this.config.schemaParsers.complex || ComplexSchemaParser;
1459
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1460
- return schemaParser.parse();
1459
+ return new (this.config.schemaParsers.complex || ComplexSchemaParser)(this, schema, typeName, this.schemaPath).parse();
1461
1460
  },
1462
1461
  [SCHEMA_TYPES$1.PRIMITIVE]: (schema, typeName) => {
1463
- const SchemaParser$1 = this.config.schemaParsers.primitive || PrimitiveSchemaParser;
1464
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1465
- return schemaParser.parse();
1462
+ return new (this.config.schemaParsers.primitive || PrimitiveSchemaParser)(this, schema, typeName, this.schemaPath).parse();
1466
1463
  },
1467
1464
  [SCHEMA_TYPES$1.DISCRIMINATOR]: (schema, typeName) => {
1468
- const SchemaParser$1 = this.config.schemaParsers.discriminator || DiscriminatorSchemaParser;
1469
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1470
- return schemaParser.parse();
1465
+ return new (this.config.schemaParsers.discriminator || DiscriminatorSchemaParser)(this, schema, typeName, this.schemaPath).parse();
1471
1466
  },
1472
1467
  [SCHEMA_TYPES$1.ARRAY]: (schema, typeName) => {
1473
- const SchemaParser$1 = this.config.schemaParsers.array || ArraySchemaParser;
1474
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1475
- return schemaParser.parse();
1468
+ return new (this.config.schemaParsers.array || ArraySchemaParser)(this, schema, typeName, this.schemaPath).parse();
1476
1469
  }
1477
1470
  };
1478
1471
  parseSchema = () => {
@@ -1509,13 +1502,11 @@ var SchemaParser = class {
1509
1502
  };
1510
1503
  getInlineParseContent = () => {
1511
1504
  const parsedSchema = this.parseSchema();
1512
- const formattedSchema = this.schemaFormatters.formatSchema(parsedSchema, "inline");
1513
- return formattedSchema.content;
1505
+ return this.schemaFormatters.formatSchema(parsedSchema, "inline").content;
1514
1506
  };
1515
1507
  getParseContent = () => {
1516
1508
  const parsedSchema = this.parseSchema();
1517
- const formattedSchema = this.schemaFormatters.formatSchema(parsedSchema, "base");
1518
- return formattedSchema.content;
1509
+ return this.schemaFormatters.formatSchema(parsedSchema, "base").content;
1519
1510
  };
1520
1511
  extractSchemaFromResponseStruct = (responseStruct) => {
1521
1512
  const { content,...extras } = responseStruct;
@@ -1613,8 +1604,7 @@ var SchemaUtils = class {
1613
1604
  const required = lodash.default.uniq([...this.getRequiredProperties(parentSchema), ...this.getRequiredProperties(childSchema)]);
1614
1605
  const refData = this.getSchemaRefType(childSchema);
1615
1606
  if (refData) {
1616
- const refObjectProperties = lodash.default.keys(refData.rawTypeData?.properties || {});
1617
- const existedRequiredKeys = refObjectProperties.filter((key) => required.includes(key));
1607
+ const existedRequiredKeys = lodash.default.keys(refData.rawTypeData?.properties || {}).filter((key) => required.includes(key));
1618
1608
  if (!existedRequiredKeys.length) return childSchema;
1619
1609
  return {
1620
1610
  ...childSchema,
@@ -1622,8 +1612,7 @@ var SchemaUtils = class {
1622
1612
  };
1623
1613
  }
1624
1614
  if (childSchema.properties) {
1625
- const childSchemaProperties = lodash.default.keys(childSchema.properties);
1626
- const existedRequiredKeys = childSchemaProperties.filter((key) => required.includes(key));
1615
+ const existedRequiredKeys = lodash.default.keys(childSchema.properties).filter((key) => required.includes(key));
1627
1616
  if (!existedRequiredKeys.length) return childSchema;
1628
1617
  return {
1629
1618
  required: lodash.default.uniq([...this.getRequiredProperties(childSchema), ...existedRequiredKeys]),
@@ -1742,28 +1731,25 @@ var SchemaParserFabric = class {
1742
1731
  return customComponent;
1743
1732
  };
1744
1733
  parseSchema = (schema, typeName = null, schemaPath = []) => {
1745
- const schemaParser = this.createSchemaParser({
1734
+ return this.createSchemaParser({
1746
1735
  schema,
1747
1736
  typeName,
1748
1737
  schemaPath
1749
- });
1750
- return schemaParser.parseSchema();
1738
+ }).parseSchema();
1751
1739
  };
1752
1740
  getInlineParseContent = (schema, typeName, schemaPath) => {
1753
- const parser = this.createSchemaParser({
1741
+ return this.createSchemaParser({
1754
1742
  schema,
1755
1743
  typeName,
1756
1744
  schemaPath
1757
- });
1758
- return parser.getInlineParseContent();
1745
+ }).getInlineParseContent();
1759
1746
  };
1760
1747
  getParseContent = (schema, typeName, schemaPath) => {
1761
- const parser = this.createSchemaParser({
1748
+ return this.createSchemaParser({
1762
1749
  schema,
1763
1750
  typeName,
1764
1751
  schemaPath
1765
- });
1766
- return parser.getParseContent();
1752
+ }).getParseContent();
1767
1753
  };
1768
1754
  };
1769
1755
 
@@ -1916,14 +1902,8 @@ var SchemaRoutes = class {
1916
1902
  }
1917
1903
  if (routeParam) routeParams[routeParam.in].push(routeParam);
1918
1904
  });
1919
- for (const pathParam of pathParamsFromRouteName) {
1920
- const alreadyExist = routeParams.path.some((parameter) => parameter.name === pathParam.name);
1921
- if (!alreadyExist) routeParams.path.push(pathParam);
1922
- }
1923
- for (const queryParam of queryParamsFromRouteName) {
1924
- const alreadyExist = routeParams.query.some((parameter) => parameter.name === queryParam.name);
1925
- if (!alreadyExist) routeParams.query.push(queryParam);
1926
- }
1905
+ for (const pathParam of pathParamsFromRouteName) if (!routeParams.path.some((parameter) => parameter.name === pathParam.name)) routeParams.path.push(pathParam);
1906
+ for (const queryParam of queryParamsFromRouteName) if (!routeParams.query.some((parameter) => parameter.name === queryParam.name)) routeParams.query.push(queryParam);
1927
1907
  return routeParams;
1928
1908
  };
1929
1909
  getContentTypes = (requestInfo, extraContentTypes) => lodash.default.uniq(lodash.default.compact([...extraContentTypes || [], ...lodash.default.flatten(lodash.default.map(requestInfo, (requestInfoData) => requestInfoData && lodash.default.keys(requestInfoData.content)))]));
@@ -2001,8 +1981,7 @@ var SchemaRoutes = class {
2001
1981
  const headerTypes = Object.fromEntries(Object.entries(src).map(([k, v]) => {
2002
1982
  return [k, this.schemaUtils.getSchemaType(v)];
2003
1983
  }));
2004
- const r = `headers: { ${Object.entries(headerTypes).map(([k, v]) => `"${k}": ${v}`).join(",")} },`;
2005
- return r;
1984
+ return `headers: { ${Object.entries(headerTypes).map(([k, v]) => `"${k}": ${v}`).join(",")} },`;
2006
1985
  };
2007
1986
  return {
2008
1987
  contentTypes,
@@ -2414,8 +2393,7 @@ var Request = class {
2414
2393
  if (authToken) requestOptions.headers = { Authorization: authToken };
2415
2394
  lodash.default.merge(requestOptions, options, this.config.requestOptions);
2416
2395
  try {
2417
- const response = await fetch(url$1, requestOptions);
2418
- return await response.text();
2396
+ return await (await fetch(url$1, requestOptions)).text();
2419
2397
  } catch (error) {
2420
2398
  const message = `error while fetching data from URL "${url$1}"`;
2421
2399
  consola.consola.error(message, error);
@@ -2506,8 +2484,7 @@ var SwaggerSchemaResolver = class {
2506
2484
  usageRouteInfo.produces = lodash.default.uniq(lodash.default.compact([...usageRouteInfo.produces || [], ...originalRouteInfo.produces || []]));
2507
2485
  }
2508
2486
  lodash.default.each(originalRouteParams, (originalRouteParam) => {
2509
- const existUsageParam = usageRouteParams.find((param) => originalRouteParam.in === param.in && originalRouteParam.name === param.name);
2510
- if (!existUsageParam) usageRouteParams.push(originalRouteParam);
2487
+ if (!usageRouteParams.find((param) => originalRouteParam.in === param.in && originalRouteParam.name === param.name)) usageRouteParams.push(originalRouteParam);
2511
2488
  });
2512
2489
  });
2513
2490
  });
@@ -2517,6 +2494,7 @@ var SwaggerSchemaResolver = class {
2517
2494
  //#endregion
2518
2495
  //#region src/templates-worker.ts
2519
2496
  const require$1 = node_module.createRequire(require("url").pathToFileURL(__filename).href);
2497
+ const eta$1 = new eta.Eta({ functionHeader: "const includeFile = options.includeFile;" });
2520
2498
  var TemplatesWorker = class {
2521
2499
  config;
2522
2500
  fileSystem;
@@ -2546,12 +2524,10 @@ var TemplatesWorker = class {
2546
2524
  cropExtension = (path$1) => this.config.templateExtensions.reduce((path$2, ext) => path$2.endsWith(ext) ? path$2.replace(ext, "") : path$2, path$1);
2547
2525
  getTemplateFullPath = (path_, fileName) => {
2548
2526
  const raw = node_path.resolve(path_, "./", this.cropExtension(fileName));
2549
- const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
2550
- return pathVariants.find((variant) => !!this.fileSystem.pathIsExist(variant));
2527
+ return this.config.templateExtensions.map((extension) => `${raw}${extension}`).find((variant) => !!this.fileSystem.pathIsExist(variant));
2551
2528
  };
2552
2529
  requireFnFromTemplate = (packageOrPath) => {
2553
- const isPath = packageOrPath.startsWith("./") || packageOrPath.startsWith("../");
2554
- if (isPath) return require$1(node_path.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
2530
+ if (packageOrPath.startsWith("./") || packageOrPath.startsWith("../")) return require$1(node_path.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
2555
2531
  return require$1(packageOrPath);
2556
2532
  };
2557
2533
  getTemplate = (name$1, fileName, path$1) => {
@@ -2581,8 +2557,7 @@ var TemplatesWorker = class {
2581
2557
  };
2582
2558
  findTemplateWithExt = (path$1) => {
2583
2559
  const raw = this.cropExtension(path$1);
2584
- const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
2585
- return pathVariants.find((variant) => this.fileSystem.pathIsExist(variant));
2560
+ return this.config.templateExtensions.map((extension) => `${raw}${extension}`).find((variant) => this.fileSystem.pathIsExist(variant));
2586
2561
  };
2587
2562
  getTemplateContent = (path_) => {
2588
2563
  const foundTemplatePathKey = lodash.default.keys(this.config.templatePaths).find((key) => path_.startsWith(`@${key}`));
@@ -2597,18 +2572,12 @@ var TemplatesWorker = class {
2597
2572
  if (originalPath) return this.fileSystem.getFileContent(originalPath);
2598
2573
  return "";
2599
2574
  };
2600
- renderTemplate = (template, configuration, options = {}) => {
2575
+ renderTemplate = (template, configuration) => {
2601
2576
  if (!template) return "";
2602
- return eta.render(template, {
2577
+ return eta$1.render(eta$1.compile(template, { async: false }), {
2603
2578
  ...this.getRenderTemplateData(),
2604
2579
  ...configuration
2605
- }, {
2606
- async: false,
2607
- ...options,
2608
- includeFile: (path$1, configuration$1, options$1 = {}) => {
2609
- return this.renderTemplate(this.getTemplateContent(path$1), configuration$1, options$1);
2610
- }
2611
- });
2580
+ }, { includeFile: (path$1, configuration$1) => this.renderTemplate(this.getTemplateContent(path$1), configuration$1) });
2612
2581
  };
2613
2582
  };
2614
2583
 
@@ -2699,10 +2668,7 @@ var TypeNameFormatter = class {
2699
2668
  isValidName = (name$1) => /^([A-Za-z$_]{1,})$/g.test(name$1);
2700
2669
  fixModelName = (name$1, options) => {
2701
2670
  if (!this.isValidName(name$1)) {
2702
- if (!/^[a-zA-Z_$]/g.test(name$1)) {
2703
- const fixPrefix = options.type === "enum-key" ? this.config.fixInvalidEnumKeyPrefix : this.config.fixInvalidTypeNamePrefix;
2704
- return `${fixPrefix} ${name$1}`;
2705
- }
2671
+ if (!/^[a-zA-Z_$]/g.test(name$1)) return `${options.type === "enum-key" ? this.config.fixInvalidEnumKeyPrefix : this.config.fixInvalidTypeNamePrefix} ${name$1}`;
2706
2672
  if (name$1.includes(".")) return name$1.replace(/Exclude_keyof[A-Za-z]+/g, () => "ExcludeKeys").replace(/%22~AND~%22/g, "And").replace(/%22~OR~%22/g, "Or").replace(/(\.?%22)|\./g, "_").replace(/__+$/, "");
2707
2673
  if (name$1.includes("-")) return lodash.default.startCase(name$1).replace(/ /g, "");
2708
2674
  }
@@ -2722,8 +2688,7 @@ var FileSystem = class {
2722
2688
  pathIsDir = (path$1) => {
2723
2689
  if (!path$1) return false;
2724
2690
  try {
2725
- const stat = node_fs.statSync(path$1);
2726
- return stat.isDirectory();
2691
+ return node_fs.statSync(path$1).isDirectory();
2727
2692
  } catch (e) {
2728
2693
  return false;
2729
2694
  }
@@ -2822,9 +2787,9 @@ var CodeGenProcess = class {
2822
2787
  typeName
2823
2788
  ]), rawTypeData);
2824
2789
  }));
2790
+ this.schemaComponentsMap.discriminatorsFirst();
2825
2791
  this.schemaComponentsMap.enumsFirst();
2826
- const componentsToParse = this.schemaComponentsMap.filter(lodash.default.compact(["schemas", this.config.extractResponses && "responses"]));
2827
- const parsedSchemas = componentsToParse.map((schemaComponent) => {
2792
+ const parsedSchemas = this.schemaComponentsMap.filter(lodash.default.compact(["schemas", this.config.extractResponses && "responses"])).map((schemaComponent) => {
2828
2793
  const parsed = this.schemaParserFabric.parseSchema(schemaComponent.rawTypeData, schemaComponent.typeName);
2829
2794
  schemaComponent.typeData = parsed;
2830
2795
  return parsed;
@@ -2859,8 +2824,7 @@ var CodeGenProcess = class {
2859
2824
  this.fileSystem.createDir(this.config.output);
2860
2825
  }
2861
2826
  const files$1 = await this.generateOutputFiles({ configuration });
2862
- const isDirPath = this.fileSystem.pathIsDir(this.config.output);
2863
- if (isDirPath) for (const file of files$1) {
2827
+ if (this.fileSystem.pathIsDir(this.config.output)) for (const file of files$1) {
2864
2828
  this.fileSystem.createFile({
2865
2829
  path: this.config.output,
2866
2830
  fileName: `${file.fileName}${file.fileExtension}`,
@@ -3141,8 +3105,7 @@ var TemplatesGenProcess = class {
3141
3105
  const templateEtaPath = node_path.default.resolve(outputPath, `${templateName}.eta`);
3142
3106
  const templateEjsPathExist = this.fileSystem.pathIsExist(templateEjsPath);
3143
3107
  const templateEtaPathExist = this.fileSystem.pathIsExist(templateEtaPath);
3144
- const templateNotExist = !templateEjsPathExist && !templateEtaPathExist;
3145
- if (templateNotExist) this.fileSystem.createFile({
3108
+ if (!templateEjsPathExist && !templateEtaPathExist) this.fileSystem.createFile({
3146
3109
  path: outputPath,
3147
3110
  fileName: template.name,
3148
3111
  content: template.content,
@@ -3212,8 +3175,7 @@ var TemplatesGenProcess = class {
3212
3175
  async function generateTemplates(config) {
3213
3176
  if (config.debug) consola.consola.level = Number.MAX_SAFE_INTEGER;
3214
3177
  if (config.silent) consola.consola.level = 0;
3215
- const codeGenProcess = new TemplatesGenProcess(config);
3216
- return await codeGenProcess.start();
3178
+ return await new TemplatesGenProcess(config).start();
3217
3179
  }
3218
3180
 
3219
3181
  //#endregion
@@ -3221,8 +3183,7 @@ async function generateTemplates(config) {
3221
3183
  async function generateApi(config) {
3222
3184
  if (config.debug) consola.consola.level = Number.MAX_SAFE_INTEGER;
3223
3185
  if (config.silent) consola.consola.level = 0;
3224
- const codeGenProcess = new CodeGenProcess(config);
3225
- return await codeGenProcess.start();
3186
+ return await new CodeGenProcess(config).start();
3226
3187
  }
3227
3188
 
3228
3189
  //#endregion
@@ -3286,4 +3247,4 @@ Object.defineProperty(exports, 'package_default', {
3286
3247
  return package_default;
3287
3248
  }
3288
3249
  });
3289
- //# sourceMappingURL=src-C5bMYV9w.cjs.map
3250
+ //# sourceMappingURL=src-D2FYrO2h.cjs.map