swagger-typescript-api 13.2.4 → 13.2.6

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.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1306](https://github.com/acacode/swagger-typescript-api/pull/1306) [`fe125cb`](https://github.com/acacode/swagger-typescript-api/commit/fe125cb6820621447f2cbf35c8bc0604fcc466dd) Thanks [@js2me](https://github.com/js2me)! - better extracting description for request body extacting types
8
+
9
+ ## 13.2.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1302](https://github.com/acacode/swagger-typescript-api/pull/1302) [`790fece`](https://github.com/acacode/swagger-typescript-api/commit/790fecea92920ecc996d90dbad5a984421e16aa8) Thanks [@js2me](https://github.com/js2me)! - added support x-propertyNames, propertyNames for object types
14
+
3
15
  ## 13.2.4
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-Dti-j_nt.cjs');
2
+ const require_src = require('./src-CKol_ydn.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-Dg3yZCMd.js";
2
+ import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-AKvd7SbK.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-Dti-j_nt.cjs');
1
+ const require_src = require('./src-CKol_ydn.cjs');
2
2
 
3
3
  Object.defineProperty(exports, 'constants', {
4
4
  enumerable: true,
package/dist/lib.d.cts CHANGED
@@ -1,6 +1,8 @@
1
1
  import { OpenAPI } from "openapi-types";
2
+ import * as typescript$1 from "typescript";
2
3
  import * as typescript from "typescript";
3
4
  import * as lodash19 from "lodash";
5
+ import * as lodash14 from "lodash";
4
6
  import lodash from "lodash";
5
7
  import * as swagger_schema_official16 from "swagger-schema-official";
6
8
  import * as eta20 from "eta";
@@ -137,6 +139,7 @@ declare class SchemaUtils {
137
139
  isRefSchema: (schema: any) => boolean;
138
140
  getEnumNames: (schema: any) => any;
139
141
  getEnumDescriptions: (schema: any) => any;
142
+ getSchemaPropertyNamesSchema: (schema: any) => any;
140
143
  getSchemaRefType: (schema: any) => SchemaComponent | null;
141
144
  isPropertyRequired: (name: any, propertySchema: any, rootSchema: any) => any;
142
145
  isNullMissingInType: (schema: any, type: any) => any;
@@ -338,14 +341,7 @@ declare class SchemaRoutes {
338
341
  };
339
342
  };
340
343
  convertRouteParamsIntoObject: (params: any) => any;
341
- getRequestBodyInfo: (routeInfo: any, routeParams: any, parsedSchemas: any, routeName: any) => {
342
- paramName: any;
343
- contentTypes: any[];
344
- contentKind: string;
345
- schema: any;
346
- type: any;
347
- required: any;
348
- };
344
+ getRequestBodyInfo: (routeInfo: any, routeParams: any, parsedSchemas: any, routeName: any) => any;
349
345
  createRequestParamsSchema: ({
350
346
  queryParams,
351
347
  queryObjectSchema,
@@ -385,7 +381,7 @@ declare class JavascriptTranslator extends Translator {
385
381
  compileTSCode: (input: TranslatorIO) => Record<string, string>;
386
382
  translate: (input: any) => Promise<{
387
383
  fileName: any;
388
- fileExtension: typescript.Extension;
384
+ fileExtension: typescript$1.Extension;
389
385
  fileContent: string;
390
386
  }[]>;
391
387
  }
@@ -1591,7 +1587,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1591
1587
  eol?: boolean | undefined;
1592
1588
  }) => string;
1593
1589
  NameResolver: typeof NameResolver;
1594
- _: lodash19.LoDashStatic;
1590
+ _: lodash14.LoDashStatic;
1595
1591
  require: (packageOrPath: string) => Promise<any>;
1596
1592
  };
1597
1593
  };
package/dist/lib.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { __export } from "./chunk-Cl8Af3a2.js";
2
1
  import * as lodash19 from "lodash";
2
+ import * as lodash14 from "lodash";
3
3
  import lodash from "lodash";
4
+ import * as typescript$1 from "typescript";
4
5
  import * as typescript from "typescript";
5
6
  import * as eta20 from "eta";
6
7
  import { OpenAPI } from "openapi-types";
@@ -136,6 +137,7 @@ declare class SchemaUtils {
136
137
  isRefSchema: (schema: any) => boolean;
137
138
  getEnumNames: (schema: any) => any;
138
139
  getEnumDescriptions: (schema: any) => any;
140
+ getSchemaPropertyNamesSchema: (schema: any) => any;
139
141
  getSchemaRefType: (schema: any) => SchemaComponent | null;
140
142
  isPropertyRequired: (name: any, propertySchema: any, rootSchema: any) => any;
141
143
  isNullMissingInType: (schema: any, type: any) => any;
@@ -337,14 +339,7 @@ declare class SchemaRoutes {
337
339
  };
338
340
  };
339
341
  convertRouteParamsIntoObject: (params: any) => any;
340
- getRequestBodyInfo: (routeInfo: any, routeParams: any, parsedSchemas: any, routeName: any) => {
341
- paramName: any;
342
- contentTypes: any[];
343
- contentKind: string;
344
- schema: any;
345
- type: any;
346
- required: any;
347
- };
342
+ getRequestBodyInfo: (routeInfo: any, routeParams: any, parsedSchemas: any, routeName: any) => any;
348
343
  createRequestParamsSchema: ({
349
344
  queryParams,
350
345
  queryObjectSchema,
@@ -384,7 +379,7 @@ declare class JavascriptTranslator extends Translator {
384
379
  compileTSCode: (input: TranslatorIO) => Record<string, string>;
385
380
  translate: (input: any) => Promise<{
386
381
  fileName: any;
387
- fileExtension: typescript.Extension;
382
+ fileExtension: typescript$1.Extension;
388
383
  fileContent: string;
389
384
  }[]>;
390
385
  }
@@ -1590,7 +1585,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1590
1585
  eol?: boolean | undefined;
1591
1586
  }) => string;
1592
1587
  NameResolver: typeof NameResolver;
1593
- _: lodash19.LoDashStatic;
1588
+ _: lodash14.LoDashStatic;
1594
1589
  require: (packageOrPath: string) => Promise<any>;
1595
1590
  };
1596
1591
  };
package/dist/lib.js CHANGED
@@ -1,3 +1,3 @@
1
- import { constants_exports, generateApi, generateTemplates } from "./src-Dg3yZCMd.js";
1
+ import { constants_exports, generateApi, generateTemplates } from "./src-AKvd7SbK.js";
2
2
 
3
3
  export { constants_exports as constants, generateApi, generateTemplates };
@@ -1,13 +1,20 @@
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";
4
7
  import * as typescript from "typescript";
8
+ import * as path$3 from "node:path";
9
+ import * as path$2 from "node:path";
5
10
  import * as path$1 from "node:path";
6
11
  import path from "node:path";
7
12
  import { Biome, Distribution } from "@biomejs/js-api";
13
+ import * as nanoid$1 from "nanoid";
8
14
  import * as nanoid from "nanoid";
9
15
  import * as yaml from "js-yaml";
10
16
  import * as swagger2openapi from "swagger2openapi";
17
+ import * as url$2 from "node:url";
11
18
  import * as url$1 from "node:url";
12
19
  import url from "node:url";
13
20
  import * as Eta from "eta";
@@ -22,11 +29,11 @@ var CodeFormatter = class {
22
29
  removeUnusedImports = (content) => {
23
30
  const tempFileName = "file.ts";
24
31
  const host = new TsLanguageServiceHost(tempFileName, content);
25
- const languageService = typescript.createLanguageService(host);
32
+ const languageService = typescript$3.createLanguageService(host);
26
33
  const fileTextChanges = languageService.organizeImports({
27
34
  type: "file",
28
35
  fileName: tempFileName
29
- }, { newLineCharacter: typescript.sys.newLine }, void 0)[0];
36
+ }, { newLineCharacter: typescript$3.sys.newLine }, void 0)[0];
30
37
  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);
31
38
  return content;
32
39
  };
@@ -37,8 +44,8 @@ var CodeFormatter = class {
37
44
  files: { maxSize: Number.MAX_SAFE_INTEGER },
38
45
  formatter: { indentStyle: "space" }
39
46
  });
40
- const formatted = biome.formatContent(biomeProject.projectKey, content, { filePath: path$1.format({
41
- name: nanoid.nanoid(),
47
+ const formatted = biome.formatContent(biomeProject.projectKey, content, { filePath: path$3.format({
48
+ name: nanoid$1.nanoid(),
42
49
  ext: "ts"
43
50
  }) });
44
51
  return formatted.content;
@@ -56,11 +63,11 @@ var TsLanguageServiceHost = class {
56
63
  constructor(fileName, content) {
57
64
  this.fileName = fileName;
58
65
  this.content = content;
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();
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();
61
68
  }
62
69
  getNewLine() {
63
- return "newLine" in typescript.sys ? typescript.sys.newLine : "\n";
70
+ return "newLine" in typescript$3.sys ? typescript$3.sys.newLine : "\n";
64
71
  }
65
72
  getScriptFileNames() {
66
73
  return [this.fileName];
@@ -69,23 +76,23 @@ var TsLanguageServiceHost = class {
69
76
  return this.compilerOptions;
70
77
  }
71
78
  getDefaultLibFileName() {
72
- return typescript.getDefaultLibFileName(this.getCompilationSettings());
79
+ return typescript$3.getDefaultLibFileName(this.getCompilationSettings());
73
80
  }
74
81
  getCurrentDirectory() {
75
82
  return process.cwd();
76
83
  }
77
84
  getScriptVersion() {
78
- return typescript.version;
85
+ return typescript$3.version;
79
86
  }
80
87
  getScriptSnapshot() {
81
- return typescript.ScriptSnapshot.fromString(this.content);
88
+ return typescript$3.ScriptSnapshot.fromString(this.content);
82
89
  }
83
90
  readFile(fileName, encoding) {
84
91
  if (fileName === this.fileName) return this.content;
85
- return typescript.sys.readFile(fileName, encoding);
92
+ return typescript$3.sys.readFile(fileName, encoding);
86
93
  }
87
- fileExists(path$2) {
88
- return typescript.sys.fileExists(path$2);
94
+ fileExists(path$4) {
95
+ return typescript$3.sys.fileExists(path$4);
89
96
  }
90
97
  };
91
98
 
@@ -155,7 +162,7 @@ const getRandomInt = (min = 0, max = 1) => {
155
162
  var ComponentTypeNameResolver = class extends NameResolver {
156
163
  counter = 1;
157
164
  fallbackNameCounter = 1;
158
- countersByVariant = /* @__PURE__ */ new Map();
165
+ countersByVariant = new Map();
159
166
  constructor(config, reservedNames) {
160
167
  super(config, reservedNames, (variants) => {
161
168
  const randomVariant = variants[getRandomInt(0, variants.length - 1)];
@@ -177,7 +184,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
177
184
  //#endregion
178
185
  //#region package.json
179
186
  var name = "swagger-typescript-api";
180
- var version = "13.2.4";
187
+ var version = "13.2.6";
181
188
  var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
182
189
  var homepage = "https://github.com/acacode/swagger-typescript-api";
183
190
  var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
@@ -218,7 +225,7 @@ var scripts = {
218
225
  };
219
226
  var dependencies = {
220
227
  "@biomejs/js-api": "1.0.0",
221
- "@biomejs/wasm-nodejs": "2.0.4",
228
+ "@biomejs/wasm-nodejs": "2.0.5",
222
229
  "@types/swagger-schema-official": "^2.0.25",
223
230
  "c12": "^3.0.4",
224
231
  "citty": "^0.1.6",
@@ -232,18 +239,18 @@ var dependencies = {
232
239
  "typescript": "~5.8.3"
233
240
  };
234
241
  var devDependencies = {
235
- "@biomejs/biome": "2.0.4",
242
+ "@biomejs/biome": "2.0.5",
236
243
  "@changesets/changelog-github": "0.5.1",
237
244
  "@changesets/cli": "2.29.5",
238
245
  "@tsconfig/node18": "18.2.4",
239
246
  "@tsconfig/strictest": "2.0.5",
240
247
  "@types/js-yaml": "4.0.9",
241
248
  "@types/lodash": "4.17.18",
242
- "@types/node": "24.0.3",
249
+ "@types/node": "24.0.4",
243
250
  "@types/swagger2openapi": "7.0.4",
244
251
  "axios": "1.10.0",
245
252
  "openapi-types": "12.1.3",
246
- "tsdown": "0.12.8",
253
+ "tsdown": "0.12.9",
247
254
  "typedoc": "0.28.5",
248
255
  "vitest": "3.2.4"
249
256
  };
@@ -426,7 +433,7 @@ var CodeGenConfig = class {
426
433
  httpClient: "http-client",
427
434
  outOfModuleApi: "Common"
428
435
  };
429
- routeNameDuplicatesMap = /* @__PURE__ */ new Map();
436
+ routeNameDuplicatesMap = new Map();
430
437
  hooks = {
431
438
  onPreBuildRoutePath: (_routePath) => void 0,
432
439
  onBuildRoutePath: (_routeData) => void 0,
@@ -536,10 +543,10 @@ var CodeGenConfig = class {
536
543
  ]
537
544
  };
538
545
  compilerTsConfig = {
539
- module: typescript.ModuleKind.ESNext,
546
+ module: typescript$2.ModuleKind.ESNext,
540
547
  noImplicitReturns: true,
541
548
  alwaysStrict: true,
542
- target: typescript.ScriptTarget.ESNext,
549
+ target: typescript$2.ScriptTarget.ESNext,
543
550
  declaration: true,
544
551
  noImplicitAny: false,
545
552
  sourceMap: false,
@@ -1249,12 +1256,21 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
1249
1256
  })
1250
1257
  };
1251
1258
  });
1252
- if (additionalProperties) propertiesContent.push({
1253
- $$raw: { additionalProperties },
1254
- description: "",
1255
- isRequired: false,
1256
- field: this.config.Ts.InterfaceDynamicField(this.config.Ts.Keyword.String, this.config.Ts.Keyword.Any)
1257
- });
1259
+ if (additionalProperties) {
1260
+ const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(schema);
1261
+ let interfaceKeysContent;
1262
+ if (propertyNamesSchema) interfaceKeysContent = this.schemaParserFabric.createSchemaParser({
1263
+ schema: propertyNamesSchema,
1264
+ schemaPath: this.schemaPath
1265
+ }).getInlineParseContent();
1266
+ else interfaceKeysContent = this.config.Ts.Keyword.String;
1267
+ propertiesContent.push({
1268
+ $$raw: { additionalProperties },
1269
+ description: "",
1270
+ isRequired: false,
1271
+ field: this.config.Ts.InterfaceDynamicField(interfaceKeysContent, this.config.Ts.Keyword.Any)
1272
+ });
1273
+ }
1258
1274
  return propertiesContent;
1259
1275
  };
1260
1276
  };
@@ -1266,11 +1282,20 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
1266
1282
  let contentType = null;
1267
1283
  const { additionalProperties, type: type$1, description: description$1, items } = this.schema || {};
1268
1284
  if (type$1 === this.config.Ts.Keyword.Object && additionalProperties) {
1269
- const fieldType = typeof additionalProperties === "object" ? this.schemaParserFabric.createSchemaParser({
1285
+ const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(this.schema);
1286
+ let recordKeysContent;
1287
+ let recordValuesContent;
1288
+ if (propertyNamesSchema) recordKeysContent = this.schemaParserFabric.createSchemaParser({
1289
+ schema: propertyNamesSchema,
1290
+ schemaPath: this.schemaPath
1291
+ }).getInlineParseContent();
1292
+ else recordKeysContent = this.config.Ts.Keyword.String;
1293
+ if (typeof additionalProperties === "object") recordValuesContent = this.schemaParserFabric.createSchemaParser({
1270
1294
  schema: additionalProperties,
1271
1295
  schemaPath: this.schemaPath
1272
- }).getInlineParseContent() : this.config.Ts.Keyword.Any;
1273
- contentType = this.config.Ts.RecordType(this.config.Ts.Keyword.String, fieldType);
1296
+ }).getInlineParseContent();
1297
+ else recordValuesContent = this.config.Ts.Keyword.Any;
1298
+ contentType = this.config.Ts.RecordType(recordKeysContent, recordValuesContent);
1274
1299
  }
1275
1300
  if (Array.isArray(type$1) && type$1.length) contentType = this.schemaParser._complexSchemaParsers.oneOf({
1276
1301
  ...typeof this.schema === "object" ? this.schema : {},
@@ -1511,6 +1536,10 @@ var SchemaUtils = class {
1511
1536
  getEnumDescriptions = (schema) => {
1512
1537
  return schema["x-enumDescriptions"] || schema.xEnumDescriptions || schema["x-enumdescriptions"] || schema["x-enum-descriptions"];
1513
1538
  };
1539
+ getSchemaPropertyNamesSchema = (schema) => {
1540
+ if (!schema) return null;
1541
+ return schema.propertyNames || schema["x-propertyNames"] || null;
1542
+ };
1514
1543
  getSchemaRefType = (schema) => {
1515
1544
  if (!this.isRefSchema(schema)) return null;
1516
1545
  return this.schemaComponentsMap.get(schema.$ref);
@@ -2014,7 +2043,9 @@ var SchemaRoutes = class {
2014
2043
  if (schema?.typeData) schema.typeData.isExtractedRequestBody = true;
2015
2044
  content = this.schemaParserFabric.getInlineParseContent({ $ref: schema.$ref });
2016
2045
  }
2046
+ if (schema && schema.typeData && !schema.typeData.description && requestBody?.description) schema.typeData.description = requestBody.description;
2017
2047
  return {
2048
+ ...requestBody || {},
2018
2049
  paramName: requestBodyName || requestBody?.name || DEFAULT_BODY_ARG_NAME,
2019
2050
  contentTypes,
2020
2051
  contentKind,
@@ -2196,6 +2227,7 @@ var SchemaRoutes = class {
2196
2227
  type: queryType
2197
2228
  } : void 0,
2198
2229
  body: requestBodyInfo.type ? {
2230
+ ...requestBodyInfo,
2199
2231
  name: nameResolver.resolve([requestBodyInfo.paramName, ...RESERVED_BODY_ARG_NAMES]),
2200
2232
  optional: !requestBodyInfo.required,
2201
2233
  type: requestBodyInfo.type
@@ -2316,8 +2348,8 @@ var SchemaRoutes = class {
2316
2348
  var SchemaWalker = class {
2317
2349
  config;
2318
2350
  swaggerSchemaResolver;
2319
- schemas = /* @__PURE__ */ new Map();
2320
- caches = /* @__PURE__ */ new Map();
2351
+ schemas = new Map();
2352
+ caches = new Map();
2321
2353
  constructor(config, swaggerSchemaResolver) {
2322
2354
  this.config = config;
2323
2355
  this.swaggerSchemaResolver = swaggerSchemaResolver;
@@ -2332,8 +2364,8 @@ var SchemaWalker = class {
2332
2364
  return ref.startsWith("http://") || ref.startsWith("https://");
2333
2365
  };
2334
2366
  _getRefDataFromSchema = (schema, ref) => {
2335
- const path$2 = ref.replace("#", "").split("/");
2336
- const refData = lodash.get(schema, path$2);
2367
+ const path$4 = ref.replace("#", "").split("/");
2368
+ const refData = lodash.get(schema, path$4);
2337
2369
  if (refData) this.caches.set(ref, refData);
2338
2370
  return refData;
2339
2371
  };
@@ -2346,15 +2378,15 @@ var Request = class {
2346
2378
  constructor(config) {
2347
2379
  this.config = config;
2348
2380
  }
2349
- async download({ url: url$2, authToken,...options }) {
2381
+ async download({ url: url$3, authToken,...options }) {
2350
2382
  const requestOptions = {};
2351
2383
  if (authToken) requestOptions.headers = { Authorization: authToken };
2352
2384
  lodash.merge(requestOptions, options, this.config.requestOptions);
2353
2385
  try {
2354
- const response = await fetch(url$2, requestOptions);
2386
+ const response = await fetch(url$3, requestOptions);
2355
2387
  return await response.text();
2356
2388
  } catch (error) {
2357
- const message = `error while fetching data from URL "${url$2}"`;
2389
+ const message = `error while fetching data from URL "${url$3}"`;
2358
2390
  consola.error(message, error);
2359
2391
  return message;
2360
2392
  }
@@ -2373,9 +2405,9 @@ var SwaggerSchemaResolver = class {
2373
2405
  this.request = new Request(config);
2374
2406
  }
2375
2407
  async create() {
2376
- const { spec, patch, input, url: url$2, authorizationToken } = this.config;
2408
+ const { spec, patch, input, url: url$3, authorizationToken } = this.config;
2377
2409
  if (spec) return await this.convertSwaggerObject(spec, { patch });
2378
- const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(input, url$2, authorizationToken);
2410
+ const swaggerSchemaFile = await this.fetchSwaggerSchemaFile(input, url$3, authorizationToken);
2379
2411
  const swaggerSchemaObject = this.processSwaggerSchemaFile(swaggerSchemaFile);
2380
2412
  return await this.convertSwaggerObject(swaggerSchemaObject, { patch });
2381
2413
  }
@@ -2465,12 +2497,12 @@ var TemplatesWorker = class {
2465
2497
  if (this.config.silent) consola.level = 0;
2466
2498
  }
2467
2499
  getTemplatePaths = (config) => {
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");
2500
+ const __dirname$1 = path$2.dirname(url$2.fileURLToPath(import.meta.url));
2501
+ const baseTemplatesPath = path$2.resolve(__dirname$1, "../templates/base");
2502
+ const defaultTemplatesPath = path$2.resolve(__dirname$1, "../templates/default");
2503
+ const modularTemplatesPath = path$2.resolve(__dirname$1, "../templates/modular");
2472
2504
  const originalTemplatesPath = config.modular ? modularTemplatesPath : defaultTemplatesPath;
2473
- const customTemplatesPath = config.templates && path$1.resolve(process.cwd(), config.templates);
2505
+ const customTemplatesPath = config.templates && path$2.resolve(process.cwd(), config.templates);
2474
2506
  return {
2475
2507
  base: baseTemplatesPath,
2476
2508
  default: defaultTemplatesPath,
@@ -2479,20 +2511,20 @@ var TemplatesWorker = class {
2479
2511
  custom: customTemplatesPath
2480
2512
  };
2481
2513
  };
2482
- cropExtension = (path$2) => this.config.templateExtensions.reduce((path$3, ext) => path$3.endsWith(ext) ? path$3.replace(ext, "") : path$3, path$2);
2514
+ cropExtension = (path$4) => this.config.templateExtensions.reduce((path$5, ext) => path$5.endsWith(ext) ? path$5.replace(ext, "") : path$5, path$4);
2483
2515
  getTemplateFullPath = (path_, fileName) => {
2484
- const raw = path$1.resolve(path_, "./", this.cropExtension(fileName));
2516
+ const raw = path$2.resolve(path_, "./", this.cropExtension(fileName));
2485
2517
  const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
2486
2518
  return pathVariants.find((variant) => !!this.fileSystem.pathIsExist(variant));
2487
2519
  };
2488
2520
  requireFnFromTemplate = async (packageOrPath) => {
2489
2521
  const isPath = packageOrPath.startsWith("./") || packageOrPath.startsWith("../");
2490
- if (isPath) return await import(path$1.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
2522
+ if (isPath) return await import(path$2.resolve(this.config.templatePaths.custom || this.config.templatePaths.original, packageOrPath));
2491
2523
  return await import(packageOrPath);
2492
2524
  };
2493
- getTemplate = (name$1, fileName, path$2) => {
2525
+ getTemplate = (name$1, fileName, path$4) => {
2494
2526
  const { templatePaths } = this.config;
2495
- if (path$2) return this.fileSystem.getFileContent(path$2);
2527
+ if (path$4) return this.fileSystem.getFileContent(path$4);
2496
2528
  if (!fileName) return "";
2497
2529
  const customFullPath = templatePaths.custom && this.getTemplateFullPath(templatePaths.custom, fileName);
2498
2530
  let fileContent = customFullPath && this.fileSystem.getFileContent(customFullPath);
@@ -2515,21 +2547,21 @@ var TemplatesWorker = class {
2515
2547
  [name$1]: this.getTemplate(name$1, fileName)
2516
2548
  }), {});
2517
2549
  };
2518
- findTemplateWithExt = (path$2) => {
2519
- const raw = this.cropExtension(path$2);
2550
+ findTemplateWithExt = (path$4) => {
2551
+ const raw = this.cropExtension(path$4);
2520
2552
  const pathVariants = this.config.templateExtensions.map((extension) => `${raw}${extension}`);
2521
2553
  return pathVariants.find((variant) => this.fileSystem.pathIsExist(variant));
2522
2554
  };
2523
2555
  getTemplateContent = (path_) => {
2524
2556
  const foundTemplatePathKey = lodash.keys(this.config.templatePaths).find((key) => path_.startsWith(`@${key}`));
2525
2557
  if (foundTemplatePathKey) {
2526
- const rawPath = path$1.resolve(path_.replace(`@${foundTemplatePathKey}`, lodash.get(this.config.templatePaths, foundTemplatePathKey)));
2558
+ const rawPath = path$2.resolve(path_.replace(`@${foundTemplatePathKey}`, lodash.get(this.config.templatePaths, foundTemplatePathKey)));
2527
2559
  const fixedPath = this.findTemplateWithExt(rawPath);
2528
2560
  if (fixedPath) return this.fileSystem.getFileContent(fixedPath);
2529
2561
  }
2530
- const customPath = this.config.templatePaths.custom && this.findTemplateWithExt(path$1.resolve(this.config.templatePaths.custom, path_));
2562
+ const customPath = this.config.templatePaths.custom && this.findTemplateWithExt(path$2.resolve(this.config.templatePaths.custom, path_));
2531
2563
  if (customPath) return this.fileSystem.getFileContent(customPath);
2532
- const originalPath = this.findTemplateWithExt(path$1.resolve(this.config.templatePaths.original, path_));
2564
+ const originalPath = this.findTemplateWithExt(path$2.resolve(this.config.templatePaths.original, path_));
2533
2565
  if (originalPath) return this.fileSystem.getFileContent(originalPath);
2534
2566
  return "";
2535
2567
  };
@@ -2541,8 +2573,8 @@ var TemplatesWorker = class {
2541
2573
  }, {
2542
2574
  async: false,
2543
2575
  ...options,
2544
- includeFile: (path$2, configuration$1, options$1 = {}) => {
2545
- return this.renderTemplate(this.getTemplateContent(path$2), configuration$1, options$1);
2576
+ includeFile: (path$4, configuration$1, options$1 = {}) => {
2577
+ return this.renderTemplate(this.getTemplateContent(path$4), configuration$1, options$1);
2546
2578
  }
2547
2579
  });
2548
2580
  };
@@ -2568,23 +2600,23 @@ var JavascriptTranslator = class extends Translator {
2568
2600
  compileTSCode = (input) => {
2569
2601
  const fileNameFull = `${input.fileName}${input.fileExtension}`;
2570
2602
  const output = {};
2571
- const host = typescript.createCompilerHost(this.config.compilerTsConfig, true);
2603
+ const host = typescript$1.createCompilerHost(this.config.compilerTsConfig, true);
2572
2604
  const fileNames = [fileNameFull];
2573
2605
  const originalSourceFileGet = host.getSourceFile.bind(host);
2574
2606
  host.getSourceFile = (sourceFileName, languageVersion, onError, shouldCreateNewSourceFile) => {
2575
2607
  if (sourceFileName !== fileNameFull) return originalSourceFileGet(sourceFileName, languageVersion, onError, shouldCreateNewSourceFile);
2576
- return typescript.createSourceFile(sourceFileName, input.fileContent, languageVersion, true, typescript.ScriptKind.TS);
2608
+ return typescript$1.createSourceFile(sourceFileName, input.fileContent, languageVersion, true, typescript$1.ScriptKind.TS);
2577
2609
  };
2578
2610
  host.writeFile = (fileName, contents) => {
2579
2611
  output[fileName] = contents;
2580
2612
  };
2581
- typescript.createProgram(fileNames, this.config.compilerTsConfig, host).emit();
2613
+ typescript$1.createProgram(fileNames, this.config.compilerTsConfig, host).emit();
2582
2614
  return output;
2583
2615
  };
2584
2616
  translate = async (input) => {
2585
2617
  const compiled = this.compileTSCode(input);
2586
- const jsFileName = `${input.fileName}${typescript.Extension.Js}`;
2587
- const dtsFileName = `${input.fileName}${typescript.Extension.Dts}`;
2618
+ const jsFileName = `${input.fileName}${typescript$1.Extension.Js}`;
2619
+ const dtsFileName = `${input.fileName}${typescript$1.Extension.Dts}`;
2588
2620
  const sourceContent = compiled[jsFileName];
2589
2621
  const tsImportRows = input.fileContent.split("\n").filter((line) => line.startsWith("import "));
2590
2622
  const declarationContent = compiled[dtsFileName].split("\n").map((line) => {
@@ -2593,11 +2625,11 @@ var JavascriptTranslator = class extends Translator {
2593
2625
  }).join("\n");
2594
2626
  return [{
2595
2627
  fileName: input.fileName,
2596
- fileExtension: typescript.Extension.Js,
2628
+ fileExtension: typescript$1.Extension.Js,
2597
2629
  fileContent: await this.codeFormatter.formatCode(sourceContent)
2598
2630
  }, {
2599
2631
  fileName: input.fileName,
2600
- fileExtension: typescript.Extension.Dts,
2632
+ fileExtension: typescript$1.Extension.Dts,
2601
2633
  fileContent: await this.codeFormatter.formatCode(declarationContent)
2602
2634
  }];
2603
2635
  };
@@ -2606,7 +2638,7 @@ var JavascriptTranslator = class extends Translator {
2606
2638
  //#endregion
2607
2639
  //#region src/type-name-formatter.ts
2608
2640
  var TypeNameFormatter = class {
2609
- formattedModelNamesMap = /* @__PURE__ */ new Map();
2641
+ formattedModelNamesMap = new Map();
2610
2642
  config;
2611
2643
  constructor(config) {
2612
2644
  this.config = config;
@@ -2649,16 +2681,16 @@ var TypeNameFormatter = class {
2649
2681
  //#endregion
2650
2682
  //#region src/util/file-system.ts
2651
2683
  var FileSystem = class {
2652
- getFileContent = (path$2) => {
2653
- return fs.readFileSync(path$2, { encoding: "utf8" });
2684
+ getFileContent = (path$4) => {
2685
+ return fs.readFileSync(path$4, { encoding: "utf8" });
2654
2686
  };
2655
- readDir = (path$2) => {
2656
- return fs.readdirSync(path$2);
2687
+ readDir = (path$4) => {
2688
+ return fs.readdirSync(path$4);
2657
2689
  };
2658
- pathIsDir = (path$2) => {
2659
- if (!path$2) return false;
2690
+ pathIsDir = (path$4) => {
2691
+ if (!path$4) return false;
2660
2692
  try {
2661
- const stat = fs.statSync(path$2);
2693
+ const stat = fs.statSync(path$4);
2662
2694
  return stat.isDirectory();
2663
2695
  } catch (e) {
2664
2696
  return false;
@@ -2669,27 +2701,27 @@ var FileSystem = class {
2669
2701
  if (fileNameParts.length > 1) fileNameParts.pop();
2670
2702
  return fileNameParts.join(".");
2671
2703
  };
2672
- removeDir = (path$2) => {
2704
+ removeDir = (path$4) => {
2673
2705
  try {
2674
- if (typeof fs.rmSync === "function") fs.rmSync(path$2, { recursive: true });
2675
- else fs.rmdirSync(path$2, { recursive: true });
2706
+ if (typeof fs.rmSync === "function") fs.rmSync(path$4, { recursive: true });
2707
+ else fs.rmdirSync(path$4, { recursive: true });
2676
2708
  } catch (e) {
2677
2709
  consola.debug("failed to remove dir", e);
2678
2710
  }
2679
2711
  };
2680
- createDir = (path$2) => {
2712
+ createDir = (path$4) => {
2681
2713
  try {
2682
- fs.mkdirSync(path$2, { recursive: true });
2714
+ fs.mkdirSync(path$4, { recursive: true });
2683
2715
  } catch (e) {
2684
2716
  consola.debug("failed to create dir", e);
2685
2717
  }
2686
2718
  };
2687
- cleanDir = (path$2) => {
2688
- this.removeDir(path$2);
2689
- this.createDir(path$2);
2719
+ cleanDir = (path$4) => {
2720
+ this.removeDir(path$4);
2721
+ this.createDir(path$4);
2690
2722
  };
2691
- pathIsExist = (path$2) => {
2692
- return !!path$2 && fs.existsSync(path$2);
2723
+ pathIsExist = (path$4) => {
2724
+ return !!path$4 && fs.existsSync(path$4);
2693
2725
  };
2694
2726
  createFile = ({ path: path_, fileName, content, withPrefix }) => {
2695
2727
  const __dirname$1 = path$1.dirname(url$1.fileURLToPath(import.meta.url));
@@ -3137,4 +3169,4 @@ async function generateApi(config) {
3137
3169
 
3138
3170
  //#endregion
3139
3171
  export { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, constants_exports, generateApi, generateTemplates, package_default };
3140
- //# sourceMappingURL=src-Dg3yZCMd.js.map
3172
+ //# sourceMappingURL=src-AKvd7SbK.js.map