swagger-typescript-api 13.2.10 → 13.2.12

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.
@@ -1,4 +1,4 @@
1
- import { __export } from "./chunk-Cl8Af3a2.js";
1
+ import { __export } from "./chunk-CTAAG5j7.js";
2
2
  import * as module from "node:module";
3
3
  import { consola } from "consola";
4
4
  import lodash from "lodash";
@@ -11,7 +11,7 @@ import * as yaml from "js-yaml";
11
11
  import * as swagger2openapi from "swagger2openapi";
12
12
  import * as url$1 from "node:url";
13
13
  import url from "node:url";
14
- import * as Eta from "eta";
14
+ import { Eta } from "eta";
15
15
  import * as fs from "node:fs";
16
16
 
17
17
  //#region src/code-formatter.ts
@@ -23,8 +23,7 @@ var CodeFormatter = class {
23
23
  removeUnusedImports = (content) => {
24
24
  const tempFileName = "file.ts";
25
25
  const host = new TsLanguageServiceHost(tempFileName, content);
26
- const languageService = typescript.createLanguageService(host);
27
- const fileTextChanges = languageService.organizeImports({
26
+ const fileTextChanges = typescript.createLanguageService(host).organizeImports({
28
27
  type: "file",
29
28
  fileName: tempFileName
30
29
  }, { newLineCharacter: typescript.sys.newLine }, void 0)[0];
@@ -38,11 +37,10 @@ var CodeFormatter = class {
38
37
  files: { maxSize: Number.MAX_SAFE_INTEGER },
39
38
  formatter: { indentStyle: "space" }
40
39
  });
41
- const formatted = biome.formatContent(biomeProject.projectKey, content, { filePath: path$1.format({
40
+ return biome.formatContent(biomeProject.projectKey, content, { filePath: path$1.format({
42
41
  name: nanoid.nanoid(),
43
42
  ext: "ts"
44
- }) });
45
- return formatted.content;
43
+ }) }).content;
46
44
  };
47
45
  formatCode = async (code, { removeUnusedImports = true, format = true } = {}) => {
48
46
  if (removeUnusedImports) code = this.removeUnusedImports(code);
@@ -178,7 +176,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
178
176
  //#endregion
179
177
  //#region package.json
180
178
  var name = "swagger-typescript-api";
181
- var version = "13.2.10";
179
+ var version = "13.2.12";
182
180
  var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
183
181
  var homepage = "https://github.com/acacode/swagger-typescript-api";
184
182
  var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
@@ -220,14 +218,16 @@ var scripts = {
220
218
  var dependencies = {
221
219
  "@biomejs/js-api": "3.0.0",
222
220
  "@biomejs/wasm-nodejs": "2.2.4",
221
+ "@types/lodash": "^4.17.20",
223
222
  "@types/swagger-schema-official": "^2.0.25",
224
- "c12": "^3.2.0",
223
+ "c12": "^3.3.0",
225
224
  "citty": "^0.1.6",
226
225
  "consola": "^3.4.2",
227
- "eta": "^2.2.0",
226
+ "eta": "^4.0.1",
228
227
  "js-yaml": "^4.1.0",
229
228
  "lodash": "^4.17.21",
230
229
  "nanoid": "^5.1.5",
230
+ "openapi-types": "^12.1.3",
231
231
  "swagger-schema-official": "2.0.0-bab6bed",
232
232
  "swagger2openapi": "^7.0.8",
233
233
  "typescript": "~5.9.2"
@@ -239,16 +239,14 @@ var devDependencies = {
239
239
  "@tsconfig/node20": "20.1.6",
240
240
  "@tsconfig/strictest": "2.0.5",
241
241
  "@types/js-yaml": "4.0.9",
242
- "@types/lodash": "4.17.20",
243
- "@types/node": "24.3.2",
242
+ "@types/node": "24.5.2",
244
243
  "@types/swagger2openapi": "7.0.4",
245
- "axios": "1.12.1",
246
- "openapi-types": "12.1.3",
247
- "tsdown": "0.15.1",
248
- "typedoc": "0.28.12",
244
+ "axios": "1.12.2",
245
+ "tsdown": "0.15.2",
246
+ "typedoc": "0.28.13",
249
247
  "vitest": "3.2.4"
250
248
  };
251
- var packageManager = "yarn@4.9.4";
249
+ var packageManager = "yarn@4.10.2";
252
250
  var engines = { "node": ">=20" };
253
251
  var publishConfig = {
254
252
  "access": "public",
@@ -287,8 +285,7 @@ var package_default = {
287
285
 
288
286
  //#endregion
289
287
  //#region src/constants.ts
290
- var constants_exports = {};
291
- __export(constants_exports, {
288
+ var constants_exports = /* @__PURE__ */ __export({
292
289
  DEFAULT_BODY_ARG_NAME: () => DEFAULT_BODY_ARG_NAME,
293
290
  FILE_PREFIX: () => FILE_PREFIX,
294
291
  HTTP_CLIENT: () => HTTP_CLIENT,
@@ -738,9 +735,9 @@ var SchemaComponentsMap = class {
738
735
  filter(...componentNames) {
739
736
  return this._data.filter((it) => componentNames.some((componentName) => it.$ref.startsWith(`#/components/${componentName}`)));
740
737
  }
741
- get($ref) {
738
+ get = ($ref) => {
742
739
  return this._data.find((c) => c.$ref === $ref) || null;
743
- }
740
+ };
744
741
  enumsFirst() {
745
742
  this._data.sort((a, b) => {
746
743
  if (Object.keys(a.rawTypeData || {}).includes("enum")) return -1;
@@ -748,6 +745,13 @@ var SchemaComponentsMap = class {
748
745
  return 0;
749
746
  });
750
747
  }
748
+ discriminatorsFirst() {
749
+ this._data.sort((a, b) => {
750
+ if (Object.keys(a.rawTypeData || {}).includes("discriminator")) return -1;
751
+ if (Object.keys(b.rawTypeData || {}).includes("discriminator")) return 1;
752
+ return 0;
753
+ });
754
+ }
751
755
  };
752
756
 
753
757
  //#endregion
@@ -811,13 +815,11 @@ var SchemaFormatters = class {
811
815
  };
812
816
  formatSchema = (parsedSchema, formatType = "base") => {
813
817
  const schemaType = lodash.get(parsedSchema, ["schemaType"]) || lodash.get(parsedSchema, ["$parsed", "schemaType"]);
814
- const formatterFn = lodash.get(this, [formatType, schemaType]);
815
- return formatterFn?.(parsedSchema) || parsedSchema;
818
+ return lodash.get(this, [formatType, schemaType])?.(parsedSchema) || parsedSchema;
816
819
  };
817
820
  formatDescription = (description$1, inline) => {
818
821
  if (!description$1) return "";
819
- const hasMultipleLines = description$1.includes("\n");
820
- if (!hasMultipleLines) return description$1;
822
+ if (!description$1.includes("\n")) return description$1;
821
823
  if (inline) return lodash._(description$1).split(/\n/g).map((part) => part.trim()).compact().join(" ").valueOf();
822
824
  return description$1.replace(/\n$/g, "");
823
825
  };
@@ -826,8 +828,7 @@ var SchemaFormatters = class {
826
828
  for (const part of content) {
827
829
  const extraSpace = " ";
828
830
  const result = `${extraSpace}${part.field},\n`;
829
- const renderedJsDoc = this.templatesWorker.renderTemplate(this.config.templatesToRender.dataContractJsDoc, { data: part });
830
- const routeNameFromTemplate = renderedJsDoc.split("\n").map((c) => `${extraSpace}${c}`).join("\n");
831
+ const routeNameFromTemplate = this.templatesWorker.renderTemplate(this.config.templatesToRender.dataContractJsDoc, { data: part }).split("\n").map((c) => `${extraSpace}${c}`).join("\n");
831
832
  if (routeNameFromTemplate) fields.push(`${routeNameFromTemplate}${result}`);
832
833
  else fields.push(`${result}`);
833
834
  }
@@ -987,7 +988,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
987
988
  suffixes: this.config.extractingOptions.discriminatorMappingSuffix,
988
989
  resolver: this.config.extractingOptions.discriminatorMappingNameResolver
989
990
  });
990
- const content$1 = ts.IntersectionType([ts.ObjectWrapper(ts.TypeField({
991
+ const content = ts.IntersectionType([ts.ObjectWrapper(ts.TypeField({
991
992
  key: ts.StringValue(discriminator.propertyName),
992
993
  value: "Key"
993
994
  })), "Type"]);
@@ -1000,21 +1001,21 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
1000
1001
  internal: true
1001
1002
  }
1002
1003
  });
1003
- component.typeData.content = content$1;
1004
+ component.typeData.content = content;
1004
1005
  mappingTypeName = this.typeNameFormatter.format(component.typeName);
1005
1006
  }
1006
1007
  /** returns (GenericType<"mapping_key", MappingType>) or ({ discriminatorProperty: "mapping_key" } & MappingType) */
1007
1008
  const createMappingContent = (mappingSchema, mappingKey) => {
1008
- const content$1 = this.schemaParserFabric.createSchemaParser({
1009
+ const content = this.schemaParserFabric.createSchemaParser({
1009
1010
  schema: mappingSchema,
1010
1011
  schemaPath: this.schemaPath
1011
1012
  }).getInlineParseContent();
1012
1013
  const mappingUsageKey = mappingPropertySchemaEnumKeysMap[mappingKey] || ts.StringValue(mappingKey);
1013
- if (ableToCreateMappingType) return ts.TypeWithGeneric(mappingTypeName, [mappingUsageKey, content$1]);
1014
+ if (ableToCreateMappingType) return ts.TypeWithGeneric(mappingTypeName, [mappingUsageKey, content]);
1014
1015
  return ts.ExpressionGroup(ts.IntersectionType([ts.ObjectWrapper(ts.TypeField({
1015
1016
  key: discriminator.propertyName,
1016
1017
  value: mappingUsageKey
1017
- })), content$1]));
1018
+ })), content]));
1018
1019
  };
1019
1020
  for (const [mappingKey, schema] of mappingEntries) {
1020
1021
  const mappingSchema = typeof schema === "string" ? { $ref: schema } : schema;
@@ -1028,8 +1029,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
1028
1029
  mappingContents.push(createMappingContent(mappingSchema, mappingKey));
1029
1030
  }
1030
1031
  if (skipMappingType) return null;
1031
- const content = ts.ExpressionGroup(ts.UnionType(mappingContents));
1032
- return { content };
1032
+ return { content: ts.ExpressionGroup(ts.UnionType(mappingContents)) };
1033
1033
  };
1034
1034
  createMappingPropertySchemaEnumKeys = ({ abstractSchemaStruct, discPropertyName }) => {
1035
1035
  const ts = this.config.Ts;
@@ -1067,8 +1067,7 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
1067
1067
  const complexSchemaKeys = lodash.keys(this.schemaParser._complexSchemaParsers);
1068
1068
  const schema = lodash.omit(structuredClone(noDiscriminatorSchema), complexSchemaKeys);
1069
1069
  const schemaIsAny = this.schemaParserFabric.getInlineParseContent(structuredClone(schema)) === this.config.Ts.Keyword.Any;
1070
- const schemaIsEmpty = !lodash.keys(schema).length;
1071
- if (schemaIsEmpty || schemaIsAny) return null;
1070
+ if (!lodash.keys(schema).length || schemaIsAny) return null;
1072
1071
  const typeName = this.schemaUtils.resolveTypeName(this.typeName, {
1073
1072
  prefixes: this.config.extractingOptions.discriminatorAbstractPrefix,
1074
1073
  resolver: this.config.extractingOptions.discriminatorAbstractResolver
@@ -1397,56 +1396,36 @@ var SchemaParser = class {
1397
1396
  }
1398
1397
  _complexSchemaParsers = {
1399
1398
  [SCHEMA_TYPES$1.COMPLEX_ONE_OF]: (schema) => {
1400
- const SchemaParser$1 = this.config.schemaParsers.complexOneOf || OneOfSchemaParser;
1401
- const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
1402
- return schemaParser.parse();
1399
+ return new (this.config.schemaParsers.complexOneOf || OneOfSchemaParser)(this, schema, null, this.schemaPath).parse();
1403
1400
  },
1404
1401
  [SCHEMA_TYPES$1.COMPLEX_ALL_OF]: (schema) => {
1405
- const SchemaParser$1 = this.config.schemaParsers.complexAllOf || AllOfSchemaParser;
1406
- const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
1407
- return schemaParser.parse();
1402
+ return new (this.config.schemaParsers.complexAllOf || AllOfSchemaParser)(this, schema, null, this.schemaPath).parse();
1408
1403
  },
1409
1404
  [SCHEMA_TYPES$1.COMPLEX_ANY_OF]: (schema) => {
1410
- const SchemaParser$1 = this.config.schemaParsers.complexAnyOf || AnyOfSchemaParser;
1411
- const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
1412
- return schemaParser.parse();
1405
+ return new (this.config.schemaParsers.complexAnyOf || AnyOfSchemaParser)(this, schema, null, this.schemaPath).parse();
1413
1406
  },
1414
1407
  [SCHEMA_TYPES$1.COMPLEX_NOT]: (schema) => {
1415
- const SchemaParser$1 = this.config.schemaParsers.complexNot || NotSchemaParser;
1416
- const schemaParser = new SchemaParser$1(this, schema, null, this.schemaPath);
1417
- return schemaParser.parse();
1408
+ return new (this.config.schemaParsers.complexNot || NotSchemaParser)(this, schema, null, this.schemaPath).parse();
1418
1409
  }
1419
1410
  };
1420
1411
  _baseSchemaParsers = {
1421
1412
  [SCHEMA_TYPES$1.ENUM]: (schema, typeName) => {
1422
- const SchemaParser$1 = this.config.schemaParsers.enum || EnumSchemaParser;
1423
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1424
- return schemaParser.parse();
1413
+ return new (this.config.schemaParsers.enum || EnumSchemaParser)(this, schema, typeName, this.schemaPath).parse();
1425
1414
  },
1426
1415
  [SCHEMA_TYPES$1.OBJECT]: (schema, typeName) => {
1427
- const SchemaParser$1 = this.config.schemaParsers.object || ObjectSchemaParser;
1428
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1429
- return schemaParser.parse();
1416
+ return new (this.config.schemaParsers.object || ObjectSchemaParser)(this, schema, typeName, this.schemaPath).parse();
1430
1417
  },
1431
1418
  [SCHEMA_TYPES$1.COMPLEX]: (schema, typeName) => {
1432
- const SchemaParser$1 = this.config.schemaParsers.complex || ComplexSchemaParser;
1433
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1434
- return schemaParser.parse();
1419
+ return new (this.config.schemaParsers.complex || ComplexSchemaParser)(this, schema, typeName, this.schemaPath).parse();
1435
1420
  },
1436
1421
  [SCHEMA_TYPES$1.PRIMITIVE]: (schema, typeName) => {
1437
- const SchemaParser$1 = this.config.schemaParsers.primitive || PrimitiveSchemaParser;
1438
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1439
- return schemaParser.parse();
1422
+ return new (this.config.schemaParsers.primitive || PrimitiveSchemaParser)(this, schema, typeName, this.schemaPath).parse();
1440
1423
  },
1441
1424
  [SCHEMA_TYPES$1.DISCRIMINATOR]: (schema, typeName) => {
1442
- const SchemaParser$1 = this.config.schemaParsers.discriminator || DiscriminatorSchemaParser;
1443
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1444
- return schemaParser.parse();
1425
+ return new (this.config.schemaParsers.discriminator || DiscriminatorSchemaParser)(this, schema, typeName, this.schemaPath).parse();
1445
1426
  },
1446
1427
  [SCHEMA_TYPES$1.ARRAY]: (schema, typeName) => {
1447
- const SchemaParser$1 = this.config.schemaParsers.array || ArraySchemaParser;
1448
- const schemaParser = new SchemaParser$1(this, schema, typeName, this.schemaPath);
1449
- return schemaParser.parse();
1428
+ return new (this.config.schemaParsers.array || ArraySchemaParser)(this, schema, typeName, this.schemaPath).parse();
1450
1429
  }
1451
1430
  };
1452
1431
  parseSchema = () => {
@@ -1483,13 +1462,11 @@ var SchemaParser = class {
1483
1462
  };
1484
1463
  getInlineParseContent = () => {
1485
1464
  const parsedSchema = this.parseSchema();
1486
- const formattedSchema = this.schemaFormatters.formatSchema(parsedSchema, "inline");
1487
- return formattedSchema.content;
1465
+ return this.schemaFormatters.formatSchema(parsedSchema, "inline").content;
1488
1466
  };
1489
1467
  getParseContent = () => {
1490
1468
  const parsedSchema = this.parseSchema();
1491
- const formattedSchema = this.schemaFormatters.formatSchema(parsedSchema, "base");
1492
- return formattedSchema.content;
1469
+ return this.schemaFormatters.formatSchema(parsedSchema, "base").content;
1493
1470
  };
1494
1471
  extractSchemaFromResponseStruct = (responseStruct) => {
1495
1472
  const { content,...extras } = responseStruct;
@@ -1587,8 +1564,7 @@ var SchemaUtils = class {
1587
1564
  const required = lodash.uniq([...this.getRequiredProperties(parentSchema), ...this.getRequiredProperties(childSchema)]);
1588
1565
  const refData = this.getSchemaRefType(childSchema);
1589
1566
  if (refData) {
1590
- const refObjectProperties = lodash.keys(refData.rawTypeData?.properties || {});
1591
- const existedRequiredKeys = refObjectProperties.filter((key) => required.includes(key));
1567
+ const existedRequiredKeys = lodash.keys(refData.rawTypeData?.properties || {}).filter((key) => required.includes(key));
1592
1568
  if (!existedRequiredKeys.length) return childSchema;
1593
1569
  return {
1594
1570
  ...childSchema,
@@ -1596,8 +1572,7 @@ var SchemaUtils = class {
1596
1572
  };
1597
1573
  }
1598
1574
  if (childSchema.properties) {
1599
- const childSchemaProperties = lodash.keys(childSchema.properties);
1600
- const existedRequiredKeys = childSchemaProperties.filter((key) => required.includes(key));
1575
+ const existedRequiredKeys = lodash.keys(childSchema.properties).filter((key) => required.includes(key));
1601
1576
  if (!existedRequiredKeys.length) return childSchema;
1602
1577
  return {
1603
1578
  required: lodash.uniq([...this.getRequiredProperties(childSchema), ...existedRequiredKeys]),
@@ -1716,28 +1691,25 @@ var SchemaParserFabric = class {
1716
1691
  return customComponent;
1717
1692
  };
1718
1693
  parseSchema = (schema, typeName = null, schemaPath = []) => {
1719
- const schemaParser = this.createSchemaParser({
1694
+ return this.createSchemaParser({
1720
1695
  schema,
1721
1696
  typeName,
1722
1697
  schemaPath
1723
- });
1724
- return schemaParser.parseSchema();
1698
+ }).parseSchema();
1725
1699
  };
1726
1700
  getInlineParseContent = (schema, typeName, schemaPath) => {
1727
- const parser = this.createSchemaParser({
1701
+ return this.createSchemaParser({
1728
1702
  schema,
1729
1703
  typeName,
1730
1704
  schemaPath
1731
- });
1732
- return parser.getInlineParseContent();
1705
+ }).getInlineParseContent();
1733
1706
  };
1734
1707
  getParseContent = (schema, typeName, schemaPath) => {
1735
- const parser = this.createSchemaParser({
1708
+ return this.createSchemaParser({
1736
1709
  schema,
1737
1710
  typeName,
1738
1711
  schemaPath
1739
- });
1740
- return parser.getParseContent();
1712
+ }).getParseContent();
1741
1713
  };
1742
1714
  };
1743
1715
 
@@ -1890,14 +1862,8 @@ var SchemaRoutes = class {
1890
1862
  }
1891
1863
  if (routeParam) routeParams[routeParam.in].push(routeParam);
1892
1864
  });
1893
- for (const pathParam of pathParamsFromRouteName) {
1894
- const alreadyExist = routeParams.path.some((parameter) => parameter.name === pathParam.name);
1895
- if (!alreadyExist) routeParams.path.push(pathParam);
1896
- }
1897
- for (const queryParam of queryParamsFromRouteName) {
1898
- const alreadyExist = routeParams.query.some((parameter) => parameter.name === queryParam.name);
1899
- if (!alreadyExist) routeParams.query.push(queryParam);
1900
- }
1865
+ for (const pathParam of pathParamsFromRouteName) if (!routeParams.path.some((parameter) => parameter.name === pathParam.name)) routeParams.path.push(pathParam);
1866
+ for (const queryParam of queryParamsFromRouteName) if (!routeParams.query.some((parameter) => parameter.name === queryParam.name)) routeParams.query.push(queryParam);
1901
1867
  return routeParams;
1902
1868
  };
1903
1869
  getContentTypes = (requestInfo, extraContentTypes) => lodash.uniq(lodash.compact([...extraContentTypes || [], ...lodash.flatten(lodash.map(requestInfo, (requestInfoData) => requestInfoData && lodash.keys(requestInfoData.content)))]));
@@ -1975,8 +1941,7 @@ var SchemaRoutes = class {
1975
1941
  const headerTypes = Object.fromEntries(Object.entries(src).map(([k, v]) => {
1976
1942
  return [k, this.schemaUtils.getSchemaType(v)];
1977
1943
  }));
1978
- const r = `headers: { ${Object.entries(headerTypes).map(([k, v]) => `"${k}": ${v}`).join(",")} },`;
1979
- return r;
1944
+ return `headers: { ${Object.entries(headerTypes).map(([k, v]) => `"${k}": ${v}`).join(",")} },`;
1980
1945
  };
1981
1946
  return {
1982
1947
  contentTypes,
@@ -2388,8 +2353,7 @@ var Request = class {
2388
2353
  if (authToken) requestOptions.headers = { Authorization: authToken };
2389
2354
  lodash.merge(requestOptions, options, this.config.requestOptions);
2390
2355
  try {
2391
- const response = await fetch(url$2, requestOptions);
2392
- return await response.text();
2356
+ return await (await fetch(url$2, requestOptions)).text();
2393
2357
  } catch (error) {
2394
2358
  const message = `error while fetching data from URL "${url$2}"`;
2395
2359
  consola.error(message, error);
@@ -2480,8 +2444,7 @@ var SwaggerSchemaResolver = class {
2480
2444
  usageRouteInfo.produces = lodash.uniq(lodash.compact([...usageRouteInfo.produces || [], ...originalRouteInfo.produces || []]));
2481
2445
  }
2482
2446
  lodash.each(originalRouteParams, (originalRouteParam) => {
2483
- const existUsageParam = usageRouteParams.find((param) => originalRouteParam.in === param.in && originalRouteParam.name === param.name);
2484
- if (!existUsageParam) usageRouteParams.push(originalRouteParam);
2447
+ if (!usageRouteParams.find((param) => originalRouteParam.in === param.in && originalRouteParam.name === param.name)) usageRouteParams.push(originalRouteParam);
2485
2448
  });
2486
2449
  });
2487
2450
  });
@@ -2491,6 +2454,7 @@ var SwaggerSchemaResolver = class {
2491
2454
  //#endregion
2492
2455
  //#region src/templates-worker.ts
2493
2456
  const require = module.createRequire(import.meta.url);
2457
+ const eta = new Eta({ functionHeader: "const includeFile = options.includeFile;" });
2494
2458
  var TemplatesWorker = class {
2495
2459
  config;
2496
2460
  fileSystem;
@@ -2520,12 +2484,10 @@ var TemplatesWorker = class {
2520
2484
  cropExtension = (path$2) => this.config.templateExtensions.reduce((path$3, ext) => path$3.endsWith(ext) ? path$3.replace(ext, "") : path$3, path$2);
2521
2485
  getTemplateFullPath = (path_, fileName) => {
2522
2486
  const raw = path$1.resolve(path_, "./", this.cropExtension(fileName));
2523
- const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
2524
- return pathVariants.find((variant) => !!this.fileSystem.pathIsExist(variant));
2487
+ return this.config.templateExtensions.map((extension) => `${raw}${extension}`).find((variant) => !!this.fileSystem.pathIsExist(variant));
2525
2488
  };
2526
2489
  requireFnFromTemplate = (packageOrPath) => {
2527
- const isPath = packageOrPath.startsWith("./") || packageOrPath.startsWith("../");
2528
- if (isPath) return require(path$1.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
2490
+ if (packageOrPath.startsWith("./") || packageOrPath.startsWith("../")) return require(path$1.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
2529
2491
  return require(packageOrPath);
2530
2492
  };
2531
2493
  getTemplate = (name$1, fileName, path$2) => {
@@ -2555,8 +2517,7 @@ var TemplatesWorker = class {
2555
2517
  };
2556
2518
  findTemplateWithExt = (path$2) => {
2557
2519
  const raw = this.cropExtension(path$2);
2558
- const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
2559
- return pathVariants.find((variant) => this.fileSystem.pathIsExist(variant));
2520
+ return this.config.templateExtensions.map((extension) => `${raw}${extension}`).find((variant) => this.fileSystem.pathIsExist(variant));
2560
2521
  };
2561
2522
  getTemplateContent = (path_) => {
2562
2523
  const foundTemplatePathKey = lodash.keys(this.config.templatePaths).find((key) => path_.startsWith(`@${key}`));
@@ -2571,18 +2532,12 @@ var TemplatesWorker = class {
2571
2532
  if (originalPath) return this.fileSystem.getFileContent(originalPath);
2572
2533
  return "";
2573
2534
  };
2574
- renderTemplate = (template, configuration, options = {}) => {
2535
+ renderTemplate = (template, configuration) => {
2575
2536
  if (!template) return "";
2576
- return Eta.render(template, {
2537
+ return eta.render(eta.compile(template, { async: false }), {
2577
2538
  ...this.getRenderTemplateData(),
2578
2539
  ...configuration
2579
- }, {
2580
- async: false,
2581
- ...options,
2582
- includeFile: (path$2, configuration$1, options$1 = {}) => {
2583
- return this.renderTemplate(this.getTemplateContent(path$2), configuration$1, options$1);
2584
- }
2585
- });
2540
+ }, { includeFile: (path$2, configuration$1) => this.renderTemplate(this.getTemplateContent(path$2), configuration$1) });
2586
2541
  };
2587
2542
  };
2588
2543
 
@@ -2673,10 +2628,7 @@ var TypeNameFormatter = class {
2673
2628
  isValidName = (name$1) => /^([A-Za-z$_]{1,})$/g.test(name$1);
2674
2629
  fixModelName = (name$1, options) => {
2675
2630
  if (!this.isValidName(name$1)) {
2676
- if (!/^[a-zA-Z_$]/g.test(name$1)) {
2677
- const fixPrefix = options.type === "enum-key" ? this.config.fixInvalidEnumKeyPrefix : this.config.fixInvalidTypeNamePrefix;
2678
- return `${fixPrefix} ${name$1}`;
2679
- }
2631
+ if (!/^[a-zA-Z_$]/g.test(name$1)) return `${options.type === "enum-key" ? this.config.fixInvalidEnumKeyPrefix : this.config.fixInvalidTypeNamePrefix} ${name$1}`;
2680
2632
  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(/__+$/, "");
2681
2633
  if (name$1.includes("-")) return lodash.startCase(name$1).replace(/ /g, "");
2682
2634
  }
@@ -2696,8 +2648,7 @@ var FileSystem = class {
2696
2648
  pathIsDir = (path$2) => {
2697
2649
  if (!path$2) return false;
2698
2650
  try {
2699
- const stat = fs.statSync(path$2);
2700
- return stat.isDirectory();
2651
+ return fs.statSync(path$2).isDirectory();
2701
2652
  } catch (e) {
2702
2653
  return false;
2703
2654
  }
@@ -2796,9 +2747,9 @@ var CodeGenProcess = class {
2796
2747
  typeName
2797
2748
  ]), rawTypeData);
2798
2749
  }));
2750
+ this.schemaComponentsMap.discriminatorsFirst();
2799
2751
  this.schemaComponentsMap.enumsFirst();
2800
- const componentsToParse = this.schemaComponentsMap.filter(lodash.compact(["schemas", this.config.extractResponses && "responses"]));
2801
- const parsedSchemas = componentsToParse.map((schemaComponent) => {
2752
+ const parsedSchemas = this.schemaComponentsMap.filter(lodash.compact(["schemas", this.config.extractResponses && "responses"])).map((schemaComponent) => {
2802
2753
  const parsed = this.schemaParserFabric.parseSchema(schemaComponent.rawTypeData, schemaComponent.typeName);
2803
2754
  schemaComponent.typeData = parsed;
2804
2755
  return parsed;
@@ -2833,8 +2784,7 @@ var CodeGenProcess = class {
2833
2784
  this.fileSystem.createDir(this.config.output);
2834
2785
  }
2835
2786
  const files$1 = await this.generateOutputFiles({ configuration });
2836
- const isDirPath = this.fileSystem.pathIsDir(this.config.output);
2837
- if (isDirPath) for (const file of files$1) {
2787
+ if (this.fileSystem.pathIsDir(this.config.output)) for (const file of files$1) {
2838
2788
  this.fileSystem.createFile({
2839
2789
  path: this.config.output,
2840
2790
  fileName: `${file.fileName}${file.fileExtension}`,
@@ -3115,8 +3065,7 @@ var TemplatesGenProcess = class {
3115
3065
  const templateEtaPath = path.resolve(outputPath, `${templateName}.eta`);
3116
3066
  const templateEjsPathExist = this.fileSystem.pathIsExist(templateEjsPath);
3117
3067
  const templateEtaPathExist = this.fileSystem.pathIsExist(templateEtaPath);
3118
- const templateNotExist = !templateEjsPathExist && !templateEtaPathExist;
3119
- if (templateNotExist) this.fileSystem.createFile({
3068
+ if (!templateEjsPathExist && !templateEtaPathExist) this.fileSystem.createFile({
3120
3069
  path: outputPath,
3121
3070
  fileName: template.name,
3122
3071
  content: template.content,
@@ -3186,8 +3135,7 @@ var TemplatesGenProcess = class {
3186
3135
  async function generateTemplates(config) {
3187
3136
  if (config.debug) consola.level = Number.MAX_SAFE_INTEGER;
3188
3137
  if (config.silent) consola.level = 0;
3189
- const codeGenProcess = new TemplatesGenProcess(config);
3190
- return await codeGenProcess.start();
3138
+ return await new TemplatesGenProcess(config).start();
3191
3139
  }
3192
3140
 
3193
3141
  //#endregion
@@ -3195,10 +3143,9 @@ async function generateTemplates(config) {
3195
3143
  async function generateApi(config) {
3196
3144
  if (config.debug) consola.level = Number.MAX_SAFE_INTEGER;
3197
3145
  if (config.silent) consola.level = 0;
3198
- const codeGenProcess = new CodeGenProcess(config);
3199
- return await codeGenProcess.start();
3146
+ return await new CodeGenProcess(config).start();
3200
3147
  }
3201
3148
 
3202
3149
  //#endregion
3203
3150
  export { CodeGenConfig, HTTP_CLIENT, RequestContentKind, SCHEMA_TYPES, TemplatesGenConfig, constants_exports, generateApi, generateTemplates, package_default };
3204
- //# sourceMappingURL=src-s8addnrG.js.map
3151
+ //# sourceMappingURL=src-LjX9fiRq.js.map