swagger-typescript-api 13.2.2 → 13.2.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # swagger-typescript-api
2
2
 
3
+ ## 13.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1299](https://github.com/acacode/swagger-typescript-api/pull/1299) [`9552c0a`](https://github.com/acacode/swagger-typescript-api/commit/9552c0a3341583be69aaa2cdf2b4e830a1919b01) Thanks [@js2me](https://github.com/js2me)! - added support of x-enum-descriptions property
8
+
9
+ ## 13.2.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1293](https://github.com/acacode/swagger-typescript-api/pull/1293) [`a87883b`](https://github.com/acacode/swagger-typescript-api/commit/a87883bdeb3e71330b8aab7d26ae62b68b51e323) Thanks [@smorimoto](https://github.com/smorimoto)! - Bump Biome to 2.0.
14
+
3
15
  ## 13.2.2
4
16
 
5
17
  ### Patch Changes
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_src = require('./src-DD5StS7t.cjs');
2
+ const require_src = require('./src-Dti-j_nt.cjs');
3
3
  const node_path = require_src.__toESM(require("node:path"));
4
4
  const c12 = require_src.__toESM(require("c12"));
5
5
  const citty = require_src.__toESM(require("citty"));
package/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-CuoIgJ3d.js";
2
+ import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-Dg3yZCMd.js";
3
3
  import * as path$1 from "node:path";
4
4
  import { loadConfig } from "c12";
5
5
  import { defineCommand, runMain } from "citty";
package/dist/lib.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_src = require('./src-DD5StS7t.cjs');
1
+ const require_src = require('./src-Dti-j_nt.cjs');
2
2
 
3
3
  Object.defineProperty(exports, 'constants', {
4
4
  enumerable: true,
package/dist/lib.d.cts CHANGED
@@ -1,8 +1,6 @@
1
1
  import { OpenAPI } from "openapi-types";
2
- import * as typescript$1 from "typescript";
3
2
  import * as typescript from "typescript";
4
3
  import * as lodash19 from "lodash";
5
- import * as lodash14 from "lodash";
6
4
  import lodash from "lodash";
7
5
  import * as swagger_schema_official16 from "swagger-schema-official";
8
6
  import * as eta20 from "eta";
@@ -138,6 +136,7 @@ declare class SchemaUtils {
138
136
  getRequiredProperties: (schema: any) => unknown[];
139
137
  isRefSchema: (schema: any) => boolean;
140
138
  getEnumNames: (schema: any) => any;
139
+ getEnumDescriptions: (schema: any) => any;
141
140
  getSchemaRefType: (schema: any) => SchemaComponent | null;
142
141
  isPropertyRequired: (name: any, propertySchema: any, rootSchema: any) => any;
143
142
  isNullMissingInType: (schema: any, type: any) => any;
@@ -386,7 +385,7 @@ declare class JavascriptTranslator extends Translator {
386
385
  compileTSCode: (input: TranslatorIO) => Record<string, string>;
387
386
  translate: (input: any) => Promise<{
388
387
  fileName: any;
389
- fileExtension: typescript$1.Extension;
388
+ fileExtension: typescript.Extension;
390
389
  fileContent: string;
391
390
  }[]>;
392
391
  }
@@ -498,6 +497,7 @@ declare class CodeGenProcess {
498
497
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
499
498
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
500
499
  EnumField: (key: unknown, value: unknown) => string;
500
+ EnumFieldDescription: (description: any) => string;
501
501
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
502
502
  ObjectWrapper: (content: unknown) => string;
503
503
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -602,6 +602,7 @@ declare class CodeGenProcess {
602
602
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
603
603
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
604
604
  EnumField: (key: unknown, value: unknown) => string;
605
+ EnumFieldDescription: (description: any) => string;
605
606
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
606
607
  ObjectWrapper: (content: unknown) => string;
607
608
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -1396,8 +1397,15 @@ declare class CodeGenConfig {
1396
1397
  */
1397
1398
  EnumField: (key: unknown, value: unknown) => string;
1398
1399
  /**
1400
+ * /\** description \*\/
1401
+ */
1402
+ EnumFieldDescription: (description: any) => string;
1403
+ /**
1404
+ * /\** $A0.description \*\/
1399
1405
  * $A0.key = $A0.value,
1406
+ * /\** $A1.description \*\/
1400
1407
  * $A1.key = $A1.value,
1408
+ * /\** $AN.description \*\/
1401
1409
  * $AN.key = $AN.value,
1402
1410
  */
1403
1411
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
@@ -1547,6 +1555,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1547
1555
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
1548
1556
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
1549
1557
  EnumField: (key: unknown, value: unknown) => string;
1558
+ EnumFieldDescription: (description: any) => string;
1550
1559
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
1551
1560
  ObjectWrapper: (content: unknown) => string;
1552
1561
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -1582,7 +1591,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1582
1591
  eol?: boolean | undefined;
1583
1592
  }) => string;
1584
1593
  NameResolver: typeof NameResolver;
1585
- _: lodash14.LoDashStatic;
1594
+ _: lodash19.LoDashStatic;
1586
1595
  require: (packageOrPath: string) => Promise<any>;
1587
1596
  };
1588
1597
  };
package/dist/lib.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import { __export } from "./chunk-Cl8Af3a2.js";
2
2
  import * as lodash19 from "lodash";
3
- import * as lodash14 from "lodash";
4
3
  import lodash from "lodash";
5
- import * as typescript$1 from "typescript";
6
4
  import * as typescript from "typescript";
7
5
  import * as eta20 from "eta";
8
6
  import { OpenAPI } from "openapi-types";
@@ -137,6 +135,7 @@ declare class SchemaUtils {
137
135
  getRequiredProperties: (schema: any) => unknown[];
138
136
  isRefSchema: (schema: any) => boolean;
139
137
  getEnumNames: (schema: any) => any;
138
+ getEnumDescriptions: (schema: any) => any;
140
139
  getSchemaRefType: (schema: any) => SchemaComponent | null;
141
140
  isPropertyRequired: (name: any, propertySchema: any, rootSchema: any) => any;
142
141
  isNullMissingInType: (schema: any, type: any) => any;
@@ -385,7 +384,7 @@ declare class JavascriptTranslator extends Translator {
385
384
  compileTSCode: (input: TranslatorIO) => Record<string, string>;
386
385
  translate: (input: any) => Promise<{
387
386
  fileName: any;
388
- fileExtension: typescript$1.Extension;
387
+ fileExtension: typescript.Extension;
389
388
  fileContent: string;
390
389
  }[]>;
391
390
  }
@@ -497,6 +496,7 @@ declare class CodeGenProcess {
497
496
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
498
497
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
499
498
  EnumField: (key: unknown, value: unknown) => string;
499
+ EnumFieldDescription: (description: any) => string;
500
500
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
501
501
  ObjectWrapper: (content: unknown) => string;
502
502
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -601,6 +601,7 @@ declare class CodeGenProcess {
601
601
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
602
602
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
603
603
  EnumField: (key: unknown, value: unknown) => string;
604
+ EnumFieldDescription: (description: any) => string;
604
605
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
605
606
  ObjectWrapper: (content: unknown) => string;
606
607
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -1395,8 +1396,15 @@ declare class CodeGenConfig {
1395
1396
  */
1396
1397
  EnumField: (key: unknown, value: unknown) => string;
1397
1398
  /**
1399
+ * /\** description \*\/
1400
+ */
1401
+ EnumFieldDescription: (description: any) => string;
1402
+ /**
1403
+ * /\** $A0.description \*\/
1398
1404
  * $A0.key = $A0.value,
1405
+ * /\** $A1.description \*\/
1399
1406
  * $A1.key = $A1.value,
1407
+ * /\** $AN.description \*\/
1400
1408
  * $AN.key = $AN.value,
1401
1409
  */
1402
1410
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
@@ -1546,6 +1554,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1546
1554
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
1547
1555
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
1548
1556
  EnumField: (key: unknown, value: unknown) => string;
1557
+ EnumFieldDescription: (description: any) => string;
1549
1558
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
1550
1559
  ObjectWrapper: (content: unknown) => string;
1551
1560
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -1581,7 +1590,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1581
1590
  eol?: boolean | undefined;
1582
1591
  }) => string;
1583
1592
  NameResolver: typeof NameResolver;
1584
- _: lodash14.LoDashStatic;
1593
+ _: lodash19.LoDashStatic;
1585
1594
  require: (packageOrPath: string) => Promise<any>;
1586
1595
  };
1587
1596
  };
package/dist/lib.js CHANGED
@@ -1,3 +1,3 @@
1
- import { constants_exports, generateApi, generateTemplates } from "./src-CuoIgJ3d.js";
1
+ import { constants_exports, generateApi, generateTemplates } from "./src-Dg3yZCMd.js";
2
2
 
3
3
  export { constants_exports as constants, generateApi, generateTemplates };
@@ -1,20 +1,13 @@
1
1
  import { __export } from "./chunk-Cl8Af3a2.js";
2
2
  import { consola } from "consola";
3
3
  import lodash from "lodash";
4
- import * as typescript$3 from "typescript";
5
- import * as typescript$2 from "typescript";
6
- import * as typescript$1 from "typescript";
7
4
  import * as typescript from "typescript";
8
- import * as path$3 from "node:path";
9
- import * as path$2 from "node:path";
10
5
  import * as path$1 from "node:path";
11
6
  import path from "node:path";
12
7
  import { Biome, Distribution } from "@biomejs/js-api";
13
- import * as nanoid$1 from "nanoid";
14
8
  import * as nanoid from "nanoid";
15
9
  import * as yaml from "js-yaml";
16
10
  import * as swagger2openapi from "swagger2openapi";
17
- import * as url$2 from "node:url";
18
11
  import * as url$1 from "node:url";
19
12
  import url from "node:url";
20
13
  import * as Eta from "eta";
@@ -29,11 +22,11 @@ var CodeFormatter = class {
29
22
  removeUnusedImports = (content) => {
30
23
  const tempFileName = "file.ts";
31
24
  const host = new TsLanguageServiceHost(tempFileName, content);
32
- const languageService = typescript$3.createLanguageService(host);
25
+ const languageService = typescript.createLanguageService(host);
33
26
  const fileTextChanges = languageService.organizeImports({
34
27
  type: "file",
35
28
  fileName: tempFileName
36
- }, { newLineCharacter: typescript$3.sys.newLine }, void 0)[0];
29
+ }, { newLineCharacter: typescript.sys.newLine }, void 0)[0];
37
30
  if (fileTextChanges?.textChanges.length) return fileTextChanges.textChanges.reduceRight((content$1, { span, newText }) => `${content$1.slice(0, span.start)}${newText}${content$1.slice(span.start + span.length)}`, content);
38
31
  return content;
39
32
  };
@@ -44,8 +37,8 @@ var CodeFormatter = class {
44
37
  files: { maxSize: Number.MAX_SAFE_INTEGER },
45
38
  formatter: { indentStyle: "space" }
46
39
  });
47
- const formatted = biome.formatContent(biomeProject.projectKey, content, { filePath: path$3.format({
48
- name: nanoid$1.nanoid(),
40
+ const formatted = biome.formatContent(biomeProject.projectKey, content, { filePath: path$1.format({
41
+ name: nanoid.nanoid(),
49
42
  ext: "ts"
50
43
  }) });
51
44
  return formatted.content;
@@ -63,11 +56,11 @@ var TsLanguageServiceHost = class {
63
56
  constructor(fileName, content) {
64
57
  this.fileName = fileName;
65
58
  this.content = content;
66
- const tsconfig = typescript$3.findConfigFile(fileName, typescript$3.sys.fileExists);
67
- this.compilerOptions = tsconfig ? typescript$3.convertCompilerOptionsFromJson(typescript$3.readConfigFile(tsconfig, typescript$3.sys.readFile).config.compilerOptions, "").options : typescript$3.getDefaultCompilerOptions();
59
+ const tsconfig = typescript.findConfigFile(fileName, typescript.sys.fileExists);
60
+ this.compilerOptions = tsconfig ? typescript.convertCompilerOptionsFromJson(typescript.readConfigFile(tsconfig, typescript.sys.readFile).config.compilerOptions, "").options : typescript.getDefaultCompilerOptions();
68
61
  }
69
62
  getNewLine() {
70
- return "newLine" in typescript$3.sys ? typescript$3.sys.newLine : "\n";
63
+ return "newLine" in typescript.sys ? typescript.sys.newLine : "\n";
71
64
  }
72
65
  getScriptFileNames() {
73
66
  return [this.fileName];
@@ -76,23 +69,23 @@ var TsLanguageServiceHost = class {
76
69
  return this.compilerOptions;
77
70
  }
78
71
  getDefaultLibFileName() {
79
- return typescript$3.getDefaultLibFileName(this.getCompilationSettings());
72
+ return typescript.getDefaultLibFileName(this.getCompilationSettings());
80
73
  }
81
74
  getCurrentDirectory() {
82
75
  return process.cwd();
83
76
  }
84
77
  getScriptVersion() {
85
- return typescript$3.version;
78
+ return typescript.version;
86
79
  }
87
80
  getScriptSnapshot() {
88
- return typescript$3.ScriptSnapshot.fromString(this.content);
81
+ return typescript.ScriptSnapshot.fromString(this.content);
89
82
  }
90
83
  readFile(fileName, encoding) {
91
84
  if (fileName === this.fileName) return this.content;
92
- return typescript$3.sys.readFile(fileName, encoding);
85
+ return typescript.sys.readFile(fileName, encoding);
93
86
  }
94
- fileExists(path$4) {
95
- return typescript$3.sys.fileExists(path$4);
87
+ fileExists(path$2) {
88
+ return typescript.sys.fileExists(path$2);
96
89
  }
97
90
  };
98
91
 
@@ -184,7 +177,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
184
177
  //#endregion
185
178
  //#region package.json
186
179
  var name = "swagger-typescript-api";
187
- var version = "13.2.2";
180
+ var version = "13.2.4";
188
181
  var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
189
182
  var homepage = "https://github.com/acacode/swagger-typescript-api";
190
183
  var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
@@ -224,8 +217,8 @@ var scripts = {
224
217
  "typedoc": "typedoc"
225
218
  };
226
219
  var dependencies = {
227
- "@biomejs/js-api": "0.8.0-beta.3",
228
- "@biomejs/wasm-nodejs": "2.0.0-beta.6",
220
+ "@biomejs/js-api": "1.0.0",
221
+ "@biomejs/wasm-nodejs": "2.0.4",
229
222
  "@types/swagger-schema-official": "^2.0.25",
230
223
  "c12": "^3.0.4",
231
224
  "citty": "^0.1.6",
@@ -239,20 +232,20 @@ var dependencies = {
239
232
  "typescript": "~5.8.3"
240
233
  };
241
234
  var devDependencies = {
242
- "@biomejs/biome": "2.0.0-beta.6",
235
+ "@biomejs/biome": "2.0.4",
243
236
  "@changesets/changelog-github": "0.5.1",
244
- "@changesets/cli": "2.29.4",
237
+ "@changesets/cli": "2.29.5",
245
238
  "@tsconfig/node18": "18.2.4",
246
239
  "@tsconfig/strictest": "2.0.5",
247
240
  "@types/js-yaml": "4.0.9",
248
- "@types/lodash": "4.17.17",
249
- "@types/node": "24.0.1",
241
+ "@types/lodash": "4.17.18",
242
+ "@types/node": "24.0.3",
250
243
  "@types/swagger2openapi": "7.0.4",
251
244
  "axios": "1.10.0",
252
245
  "openapi-types": "12.1.3",
253
- "tsdown": "0.12.7",
246
+ "tsdown": "0.12.8",
254
247
  "typedoc": "0.28.5",
255
- "vitest": "3.2.3"
248
+ "vitest": "3.2.4"
256
249
  };
257
250
  var packageManager = "yarn@4.9.2";
258
251
  var engines = { "node": ">=20" };
@@ -543,10 +536,10 @@ var CodeGenConfig = class {
543
536
  ]
544
537
  };
545
538
  compilerTsConfig = {
546
- module: typescript$2.ModuleKind.ESNext,
539
+ module: typescript.ModuleKind.ESNext,
547
540
  noImplicitReturns: true,
548
541
  alwaysStrict: true,
549
- target: typescript$2.ScriptTarget.ESNext,
542
+ target: typescript.ScriptTarget.ESNext,
550
543
  declaration: true,
551
544
  noImplicitAny: false,
552
545
  sourceMap: false,
@@ -582,7 +575,13 @@ var CodeGenConfig = class {
582
575
  InterfaceDynamicField: (key, value) => `[key: ${key}]: ${value}`,
583
576
  EnumUsageKey: (enumStruct, key) => `${enumStruct}.${key}`,
584
577
  EnumField: (key, value) => `${key} = ${value}`,
585
- EnumFieldsWrapper: (contents) => lodash.map(contents, ({ key, value }) => ` ${this.Ts.EnumField(key, value)}`).join(",\n"),
578
+ EnumFieldDescription: (description$1) => {
579
+ if (description$1) return ` /** ${description$1} */`;
580
+ else return "";
581
+ },
582
+ EnumFieldsWrapper: (contents) => lodash.map(contents, ({ key, value, description: description$1 }) => {
583
+ return [this.Ts.EnumFieldDescription(description$1), ` ${this.Ts.EnumField(key, value)}`].filter(Boolean).join("\n");
584
+ }).join(",\n"),
586
585
  ObjectWrapper: (content) => `{\n${content}\n}`,
587
586
  MultilineComment: (contents, formatFn) => [...contents.length === 1 ? [`/** ${contents[0]} */`] : [
588
587
  "/**",
@@ -1146,6 +1145,7 @@ var EnumSchemaParser = class extends MonoSchemaParser {
1146
1145
  })) }, this.typeName, this.schemaPath);
1147
1146
  const keyType = this.schemaUtils.getSchemaType(this.schema);
1148
1147
  const enumNames = this.schemaUtils.getEnumNames(this.schema);
1148
+ const enumDescriptions = this.schemaUtils.getEnumDescriptions(this.schema);
1149
1149
  let content = null;
1150
1150
  const formatValue = (value) => {
1151
1151
  if (value === null) return this.config.Ts.NullValue(value);
@@ -1162,19 +1162,22 @@ var EnumSchemaParser = class extends MonoSchemaParser {
1162
1162
  if (this.config.enumNamesAsValues || enumValue === void 0) return {
1163
1163
  key: formattedKey,
1164
1164
  type: this.config.Ts.Keyword.String,
1165
- value: this.config.Ts.StringValue(enumName)
1165
+ value: this.config.Ts.StringValue(enumName),
1166
+ description: enumDescriptions?.[index]
1166
1167
  };
1167
1168
  return {
1168
1169
  key: formattedKey,
1169
1170
  type: keyType,
1170
- value: formatValue(enumValue)
1171
+ value: formatValue(enumValue),
1172
+ description: enumDescriptions?.[index]
1171
1173
  };
1172
1174
  });
1173
- else content = this.schema.enum.map((value) => {
1175
+ else content = this.schema.enum.map((value, index) => {
1174
1176
  return {
1175
1177
  key: this.formatEnumKey({ value }),
1176
1178
  type: keyType,
1177
- value: formatValue(value)
1179
+ value: formatValue(value),
1180
+ description: enumDescriptions?.[index]
1178
1181
  };
1179
1182
  });
1180
1183
  return {
@@ -1505,6 +1508,9 @@ var SchemaUtils = class {
1505
1508
  getEnumNames = (schema) => {
1506
1509
  return schema["x-enumNames"] || schema.xEnumNames || schema["x-enumnames"] || schema["x-enum-varnames"];
1507
1510
  };
1511
+ getEnumDescriptions = (schema) => {
1512
+ return schema["x-enumDescriptions"] || schema.xEnumDescriptions || schema["x-enumdescriptions"] || schema["x-enum-descriptions"];
1513
+ };
1508
1514
  getSchemaRefType = (schema) => {
1509
1515
  if (!this.isRefSchema(schema)) return null;
1510
1516
  return this.schemaComponentsMap.get(schema.$ref);
@@ -2326,8 +2332,8 @@ var SchemaWalker = class {
2326
2332
  return ref.startsWith("http://") || ref.startsWith("https://");
2327
2333
  };
2328
2334
  _getRefDataFromSchema = (schema, ref) => {
2329
- const path$4 = ref.replace("#", "").split("/");
2330
- const refData = lodash.get(schema, path$4);
2335
+ const path$2 = ref.replace("#", "").split("/");
2336
+ const refData = lodash.get(schema, path$2);
2331
2337
  if (refData) this.caches.set(ref, refData);
2332
2338
  return refData;
2333
2339
  };
@@ -2340,15 +2346,15 @@ var Request = class {
2340
2346
  constructor(config) {
2341
2347
  this.config = config;
2342
2348
  }
2343
- async download({ url: url$3, authToken,...options }) {
2349
+ async download({ url: url$2, authToken,...options }) {
2344
2350
  const requestOptions = {};
2345
2351
  if (authToken) requestOptions.headers = { Authorization: authToken };
2346
2352
  lodash.merge(requestOptions, options, this.config.requestOptions);
2347
2353
  try {
2348
- const response = await fetch(url$3, requestOptions);
2354
+ const response = await fetch(url$2, requestOptions);
2349
2355
  return await response.text();
2350
2356
  } catch (error) {
2351
- const message = `error while fetching data from URL "${url$3}"`;
2357
+ const message = `error while fetching data from URL "${url$2}"`;
2352
2358
  consola.error(message, error);
2353
2359
  return message;
2354
2360
  }
@@ -2367,9 +2373,9 @@ var SwaggerSchemaResolver = class {
2367
2373
  this.request = new Request(config);
2368
2374
  }
2369
2375
  async create() {
2370
- const { spec, patch, input, url: url$3, authorizationToken } = this.config;
2376
+ const { spec, patch, input, url: url$2, authorizationToken } = this.config;
2371
2377
  if (spec) return await this.convertSwaggerObject(spec, { patch });
2372
- const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(input, url$3, authorizationToken);
2378
+ const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(input, url$2, authorizationToken);
2373
2379
  const swaggerSchemaObject = this.processSwaggerSchemaFile(swaggerSchemaFile);
2374
2380
  return await this.convertSwaggerObject(swaggerSchemaObject, { patch });
2375
2381
  }
@@ -2459,12 +2465,12 @@ var TemplatesWorker = class {
2459
2465
  if (this.config.silent) consola.level = 0;
2460
2466
  }
2461
2467
  getTemplatePaths = (config) => {
2462
- const __dirname$1 = path$2.dirname(url$2.fileURLToPath(import.meta.url));
2463
- const baseTemplatesPath = path$2.resolve(__dirname$1, "../templates/base");
2464
- const defaultTemplatesPath = path$2.resolve(__dirname$1, "../templates/default");
2465
- const modularTemplatesPath = path$2.resolve(__dirname$1, "../templates/modular");
2468
+ const __dirname$1 = path$1.dirname(url$1.fileURLToPath(import.meta.url));
2469
+ const baseTemplatesPath = path$1.resolve(__dirname$1, "../templates/base");
2470
+ const defaultTemplatesPath = path$1.resolve(__dirname$1, "../templates/default");
2471
+ const modularTemplatesPath = path$1.resolve(__dirname$1, "../templates/modular");
2466
2472
  const originalTemplatesPath = config.modular ? modularTemplatesPath : defaultTemplatesPath;
2467
- const customTemplatesPath = config.templates && path$2.resolve(process.cwd(), config.templates);
2473
+ const customTemplatesPath = config.templates && path$1.resolve(process.cwd(), config.templates);
2468
2474
  return {
2469
2475
  base: baseTemplatesPath,
2470
2476
  default: defaultTemplatesPath,
@@ -2473,20 +2479,20 @@ var TemplatesWorker = class {
2473
2479
  custom: customTemplatesPath
2474
2480
  };
2475
2481
  };
2476
- cropExtension = (path$4) => this.config.templateExtensions.reduce((path$5, ext) => path$5.endsWith(ext) ? path$5.replace(ext, "") : path$5, path$4);
2482
+ cropExtension = (path$2) => this.config.templateExtensions.reduce((path$3, ext) => path$3.endsWith(ext) ? path$3.replace(ext, "") : path$3, path$2);
2477
2483
  getTemplateFullPath = (path_, fileName) => {
2478
- const raw = path$2.resolve(path_, "./", this.cropExtension(fileName));
2484
+ const raw = path$1.resolve(path_, "./", this.cropExtension(fileName));
2479
2485
  const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
2480
2486
  return pathVariants.find((variant) => !!this.fileSystem.pathIsExist(variant));
2481
2487
  };
2482
2488
  requireFnFromTemplate = async (packageOrPath) => {
2483
2489
  const isPath = packageOrPath.startsWith("./") || packageOrPath.startsWith("../");
2484
- if (isPath) return await import(path$2.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
2490
+ if (isPath) return await import(path$1.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
2485
2491
  return await import(packageOrPath);
2486
2492
  };
2487
- getTemplate = (name$1, fileName, path$4) => {
2493
+ getTemplate = (name$1, fileName, path$2) => {
2488
2494
  const { templatePaths } = this.config;
2489
- if (path$4) return this.fileSystem.getFileContent(path$4);
2495
+ if (path$2) return this.fileSystem.getFileContent(path$2);
2490
2496
  if (!fileName) return "";
2491
2497
  const customFullPath = templatePaths.custom && this.getTemplateFullPath(templatePaths.custom, fileName);
2492
2498
  let fileContent = customFullPath && this.fileSystem.getFileContent(customFullPath);
@@ -2509,21 +2515,21 @@ var TemplatesWorker = class {
2509
2515
  [name$1]: this.getTemplate(name$1, fileName)
2510
2516
  }), {});
2511
2517
  };
2512
- findTemplateWithExt = (path$4) => {
2513
- const raw = this.cropExtension(path$4);
2518
+ findTemplateWithExt = (path$2) => {
2519
+ const raw = this.cropExtension(path$2);
2514
2520
  const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
2515
2521
  return pathVariants.find((variant) => this.fileSystem.pathIsExist(variant));
2516
2522
  };
2517
2523
  getTemplateContent = (path_) => {
2518
2524
  const foundTemplatePathKey = lodash.keys(this.config.templatePaths).find((key) => path_.startsWith(`@${key}`));
2519
2525
  if (foundTemplatePathKey) {
2520
- const rawPath = path$2.resolve(path_.replace(`@${foundTemplatePathKey}`, lodash.get(this.config.templatePaths, foundTemplatePathKey)));
2526
+ const rawPath = path$1.resolve(path_.replace(`@${foundTemplatePathKey}`, lodash.get(this.config.templatePaths, foundTemplatePathKey)));
2521
2527
  const fixedPath = this.findTemplateWithExt(rawPath);
2522
2528
  if (fixedPath) return this.fileSystem.getFileContent(fixedPath);
2523
2529
  }
2524
- const customPath = this.config.templatePaths.custom && this.findTemplateWithExt(path$2.resolve(this.config.templatePaths.custom, path_));
2530
+ const customPath = this.config.templatePaths.custom && this.findTemplateWithExt(path$1.resolve(this.config.templatePaths.custom, path_));
2525
2531
  if (customPath) return this.fileSystem.getFileContent(customPath);
2526
- const originalPath = this.findTemplateWithExt(path$2.resolve(this.config.templatePaths.original, path_));
2532
+ const originalPath = this.findTemplateWithExt(path$1.resolve(this.config.templatePaths.original, path_));
2527
2533
  if (originalPath) return this.fileSystem.getFileContent(originalPath);
2528
2534
  return "";
2529
2535
  };
@@ -2535,8 +2541,8 @@ var TemplatesWorker = class {
2535
2541
  }, {
2536
2542
  async: false,
2537
2543
  ...options,
2538
- includeFile: (path$4, configuration$1, options$1 = {}) => {
2539
- return this.renderTemplate(this.getTemplateContent(path$4), configuration$1, options$1);
2544
+ includeFile: (path$2, configuration$1, options$1 = {}) => {
2545
+ return this.renderTemplate(this.getTemplateContent(path$2), configuration$1, options$1);
2540
2546
  }
2541
2547
  });
2542
2548
  };
@@ -2562,23 +2568,23 @@ var JavascriptTranslator = class extends Translator {
2562
2568
  compileTSCode = (input) => {
2563
2569
  const fileNameFull = `${input.fileName}${input.fileExtension}`;
2564
2570
  const output = {};
2565
- const host = typescript$1.createCompilerHost(this.config.compilerTsConfig, true);
2571
+ const host = typescript.createCompilerHost(this.config.compilerTsConfig, true);
2566
2572
  const fileNames = [fileNameFull];
2567
2573
  const originalSourceFileGet = host.getSourceFile.bind(host);
2568
2574
  host.getSourceFile = (sourceFileName, languageVersion, onError, shouldCreateNewSourceFile) => {
2569
2575
  if (sourceFileName !== fileNameFull) return originalSourceFileGet(sourceFileName, languageVersion, onError, shouldCreateNewSourceFile);
2570
- return typescript$1.createSourceFile(sourceFileName, input.fileContent, languageVersion, true, typescript$1.ScriptKind.TS);
2576
+ return typescript.createSourceFile(sourceFileName, input.fileContent, languageVersion, true, typescript.ScriptKind.TS);
2571
2577
  };
2572
2578
  host.writeFile = (fileName, contents) => {
2573
2579
  output[fileName] = contents;
2574
2580
  };
2575
- typescript$1.createProgram(fileNames, this.config.compilerTsConfig, host).emit();
2581
+ typescript.createProgram(fileNames, this.config.compilerTsConfig, host).emit();
2576
2582
  return output;
2577
2583
  };
2578
2584
  translate = async (input) => {
2579
2585
  const compiled = this.compileTSCode(input);
2580
- const jsFileName = `${input.fileName}${typescript$1.Extension.Js}`;
2581
- const dtsFileName = `${input.fileName}${typescript$1.Extension.Dts}`;
2586
+ const jsFileName = `${input.fileName}${typescript.Extension.Js}`;
2587
+ const dtsFileName = `${input.fileName}${typescript.Extension.Dts}`;
2582
2588
  const sourceContent = compiled[jsFileName];
2583
2589
  const tsImportRows = input.fileContent.split("\n").filter((line) => line.startsWith("import "));
2584
2590
  const declarationContent = compiled[dtsFileName].split("\n").map((line) => {
@@ -2587,11 +2593,11 @@ var JavascriptTranslator = class extends Translator {
2587
2593
  }).join("\n");
2588
2594
  return [{
2589
2595
  fileName: input.fileName,
2590
- fileExtension: typescript$1.Extension.Js,
2596
+ fileExtension: typescript.Extension.Js,
2591
2597
  fileContent: await this.codeFormatter.formatCode(sourceContent)
2592
2598
  }, {
2593
2599
  fileName: input.fileName,
2594
- fileExtension: typescript$1.Extension.Dts,
2600
+ fileExtension: typescript.Extension.Dts,
2595
2601
  fileContent: await this.codeFormatter.formatCode(declarationContent)
2596
2602
  }];
2597
2603
  };
@@ -2643,16 +2649,16 @@ var TypeNameFormatter = class {
2643
2649
  //#endregion
2644
2650
  //#region src/util/file-system.ts
2645
2651
  var FileSystem = class {
2646
- getFileContent = (path$4) => {
2647
- return fs.readFileSync(path$4, { encoding: "utf8" });
2652
+ getFileContent = (path$2) => {
2653
+ return fs.readFileSync(path$2, { encoding: "utf8" });
2648
2654
  };
2649
- readDir = (path$4) => {
2650
- return fs.readdirSync(path$4);
2655
+ readDir = (path$2) => {
2656
+ return fs.readdirSync(path$2);
2651
2657
  };
2652
- pathIsDir = (path$4) => {
2653
- if (!path$4) return false;
2658
+ pathIsDir = (path$2) => {
2659
+ if (!path$2) return false;
2654
2660
  try {
2655
- const stat = fs.statSync(path$4);
2661
+ const stat = fs.statSync(path$2);
2656
2662
  return stat.isDirectory();
2657
2663
  } catch (e) {
2658
2664
  return false;
@@ -2663,27 +2669,27 @@ var FileSystem = class {
2663
2669
  if (fileNameParts.length > 1) fileNameParts.pop();
2664
2670
  return fileNameParts.join(".");
2665
2671
  };
2666
- removeDir = (path$4) => {
2672
+ removeDir = (path$2) => {
2667
2673
  try {
2668
- if (typeof fs.rmSync === "function") fs.rmSync(path$4, { recursive: true });
2669
- else fs.rmdirSync(path$4, { recursive: true });
2674
+ if (typeof fs.rmSync === "function") fs.rmSync(path$2, { recursive: true });
2675
+ else fs.rmdirSync(path$2, { recursive: true });
2670
2676
  } catch (e) {
2671
2677
  consola.debug("failed to remove dir", e);
2672
2678
  }
2673
2679
  };
2674
- createDir = (path$4) => {
2680
+ createDir = (path$2) => {
2675
2681
  try {
2676
- fs.mkdirSync(path$4, { recursive: true });
2682
+ fs.mkdirSync(path$2, { recursive: true });
2677
2683
  } catch (e) {
2678
2684
  consola.debug("failed to create dir", e);
2679
2685
  }
2680
2686
  };
2681
- cleanDir = (path$4) => {
2682
- this.removeDir(path$4);
2683
- this.createDir(path$4);
2687
+ cleanDir = (path$2) => {
2688
+ this.removeDir(path$2);
2689
+ this.createDir(path$2);
2684
2690
  };
2685
- pathIsExist = (path$4) => {
2686
- return !!path$4 && fs.existsSync(path$4);
2691
+ pathIsExist = (path$2) => {
2692
+ return !!path$2 && fs.existsSync(path$2);
2687
2693
  };
2688
2694
  createFile = ({ path: path_, fileName, content, withPrefix }) => {
2689
2695
  const __dirname$1 = path$1.dirname(url$1.fileURLToPath(import.meta.url));
@@ -3131,4 +3137,4 @@ async function generateApi(config) {
3131
3137
 
3132
3138
  //#endregion
3133
3139
  export { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, constants_exports, generateApi, generateTemplates, package_default };
3134
- //# sourceMappingURL=src-CuoIgJ3d.js.map
3140
+ //# sourceMappingURL=src-Dg3yZCMd.js.map