swagger-typescript-api 13.2.15 → 13.2.16

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.
@@ -216,112 +216,8 @@ var ComponentTypeNameResolver = class extends NameResolver {
216
216
  //#endregion
217
217
  //#region package.json
218
218
  var name = "swagger-typescript-api";
219
- var version = "13.2.15";
219
+ var version = "13.2.16";
220
220
  var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
221
- var homepage = "https://github.com/acacode/swagger-typescript-api";
222
- var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
223
- var repository = "github:acacode/swagger-typescript-api";
224
- var license = "MIT";
225
- var author = "Sergey Volkov <js2me@outlook.com>";
226
- var maintainers = ["Sora Morimoto <sora@morimoto.io>"];
227
- var type = "module";
228
- var exports$1 = {
229
- ".": {
230
- "import": "./dist/index.js",
231
- "require": "./dist/index.cjs"
232
- },
233
- "./cli": {
234
- "import": "./dist/cli.js",
235
- "require": "./dist/cli.cjs"
236
- },
237
- "./package.json": "./package.json"
238
- };
239
- var main = "./dist/index.cjs";
240
- var module$1 = "./dist/index.js";
241
- var types = "./dist/index.d.cts";
242
- var bin = {
243
- "sta": "./dist/cli.js",
244
- "swagger-typescript-api": "./dist/cli.js"
245
- };
246
- var files = ["dist", "templates"];
247
- var scripts = {
248
- "build": "tsdown",
249
- "cli:help": "node index.js -h",
250
- "cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts",
251
- "cli:yaml": "node index.js -r -d -p ./swagger-test-cli.yaml -n swagger-test-cli.ts",
252
- "format": "biome format --write .",
253
- "format:check": "biome format .",
254
- "lint": "biome check",
255
- "prepack": "tsdown",
256
- "test": "vitest run",
257
- "typedoc": "typedoc"
258
- };
259
- var dependencies = {
260
- "@biomejs/js-api": "3.0.0",
261
- "@biomejs/wasm-nodejs": "2.2.5",
262
- "@types/lodash": "^4.17.20",
263
- "@types/swagger-schema-official": "^2.0.25",
264
- "c12": "^3.3.0",
265
- "citty": "^0.1.6",
266
- "consola": "^3.4.2",
267
- "eta": "^4.0.1",
268
- "lodash": "^4.17.21",
269
- "nanoid": "^5.1.6",
270
- "openapi-types": "^12.1.3",
271
- "swagger-schema-official": "2.0.0-bab6bed",
272
- "swagger2openapi": "^7.0.8",
273
- "typescript": "~5.9.3",
274
- "yaml": "^2.8.1"
275
- };
276
- var devDependencies = {
277
- "@biomejs/biome": "2.2.5",
278
- "@changesets/changelog-github": "0.5.1",
279
- "@changesets/cli": "2.29.7",
280
- "@tsconfig/node20": "20.1.6",
281
- "@tsconfig/strictest": "2.0.6",
282
- "@types/node": "24.7.0",
283
- "@types/swagger2openapi": "7.0.4",
284
- "axios": "1.12.2",
285
- "tsdown": "0.15.6",
286
- "typedoc": "0.28.13",
287
- "vitest": "3.2.4"
288
- };
289
- var packageManager = "yarn@4.10.3";
290
- var engines = { "node": ">=20" };
291
- var publishConfig = {
292
- "access": "public",
293
- "provenance": true,
294
- "registry": "https://registry.npmjs.org"
295
- };
296
- var typedocOptions = {
297
- "entryPoints": ["src/index.ts"],
298
- "skipErrorChecking": true
299
- };
300
- var package_default = {
301
- name,
302
- version,
303
- description,
304
- homepage,
305
- bugs,
306
- repository,
307
- license,
308
- author,
309
- maintainers,
310
- type,
311
- exports: exports$1,
312
- main,
313
- module: module$1,
314
- types,
315
- bin,
316
- files,
317
- scripts,
318
- dependencies,
319
- devDependencies,
320
- packageManager,
321
- engines,
322
- publishConfig,
323
- typedocOptions
324
- };
325
221
 
326
222
  //#endregion
327
223
  //#region src/constants.ts
@@ -355,7 +251,7 @@ const HTTP_CLIENT = {
355
251
  FETCH: "fetch",
356
252
  AXIOS: "axios"
357
253
  };
358
- const PROJECT_VERSION = package_default.version;
254
+ const PROJECT_VERSION = version;
359
255
  const RESERVED_BODY_ARG_NAMES = [
360
256
  "data",
361
257
  "body",
@@ -754,13 +650,11 @@ var SchemaComponentsMap = class {
754
650
  };
755
651
  createComponent($ref, rawTypeData) {
756
652
  const parsed = this.parseRef($ref);
757
- const typeName = parsed[parsed.length - 1];
758
- const componentName = parsed[parsed.length - 2];
759
653
  const componentSchema = {
760
654
  $ref,
761
- typeName,
655
+ typeName: parsed[parsed.length - 1],
762
656
  rawTypeData,
763
- componentName,
657
+ componentName: parsed[parsed.length - 2],
764
658
  typeData: null
765
659
  };
766
660
  const usageComponent = this.config.hooks.onCreateComponent(componentSchema) || componentSchema;
@@ -922,8 +816,8 @@ var MonoSchemaParser = class {
922
816
  var ArraySchemaParser = class extends MonoSchemaParser {
923
817
  parse() {
924
818
  let contentType;
925
- const { type: type$1, description: description$1, items } = this.schema || {};
926
- if (Array.isArray(items) && type$1 === SCHEMA_TYPES$1.ARRAY) {
819
+ const { type, description: description$1, items } = this.schema || {};
820
+ if (Array.isArray(items) && type === SCHEMA_TYPES$1.ARRAY) {
927
821
  const tupleContent = [];
928
822
  for (const item of items) tupleContent.push(this.schemaParserFabric.createSchemaParser({
929
823
  schema: item,
@@ -1124,14 +1018,13 @@ var DiscriminatorSchemaParser = class extends MonoSchemaParser {
1124
1018
  ...schema,
1125
1019
  internal: true
1126
1020
  });
1127
- const content = this.schemaParserFabric.createSchemaParser({
1128
- schema: component,
1129
- schemaPath: this.schemaPath
1130
- }).getInlineParseContent();
1131
1021
  return {
1132
1022
  typeName,
1133
1023
  component,
1134
- content
1024
+ content: this.schemaParserFabric.createSchemaParser({
1025
+ schema: component,
1026
+ schemaPath: this.schemaPath
1027
+ }).getInlineParseContent()
1135
1028
  };
1136
1029
  };
1137
1030
  createComplexSchemaStruct = () => {
@@ -1328,8 +1221,8 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
1328
1221
  var PrimitiveSchemaParser = class extends MonoSchemaParser {
1329
1222
  parse() {
1330
1223
  let contentType = null;
1331
- const { additionalProperties, type: type$1, description: description$1, items } = this.schema || {};
1332
- if (type$1 === this.config.Ts.Keyword.Object && additionalProperties) {
1224
+ const { additionalProperties, type, description: description$1, items } = this.schema || {};
1225
+ if (type === this.config.Ts.Keyword.Object && additionalProperties) {
1333
1226
  const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(this.schema);
1334
1227
  let recordKeysContent;
1335
1228
  let recordValuesContent;
@@ -1345,11 +1238,11 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
1345
1238
  else recordValuesContent = this.config.Ts.Keyword.Any;
1346
1239
  contentType = this.config.Ts.RecordType(recordKeysContent, recordValuesContent);
1347
1240
  }
1348
- if (Array.isArray(type$1) && type$1.length) contentType = this.schemaParser._complexSchemaParsers.oneOf({
1241
+ if (Array.isArray(type) && type.length) contentType = this.schemaParser._complexSchemaParsers.oneOf({
1349
1242
  ...typeof this.schema === "object" ? this.schema : {},
1350
- oneOf: type$1.map((type$2) => ({ type: type$2 }))
1243
+ oneOf: type.map((type$1) => ({ type: type$1 }))
1351
1244
  });
1352
- if (Array.isArray(items) && type$1 === SCHEMA_TYPES$1.ARRAY) contentType = this.config.Ts.Tuple(items.map((item) => this.schemaParserFabric.createSchemaParser({
1245
+ if (Array.isArray(items) && type === SCHEMA_TYPES$1.ARRAY) contentType = this.config.Ts.Tuple(items.map((item) => this.schemaParserFabric.createSchemaParser({
1353
1246
  schema: item,
1354
1247
  schemaPath: this.schemaPath
1355
1248
  }).getInlineParseContent()));
@@ -1362,7 +1255,7 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
1362
1255
  typeIdentifier: this.config.Ts.Keyword.Type,
1363
1256
  name: this.typeName,
1364
1257
  description: this.schemaFormatters.formatDescription(description$1),
1365
- content: type$1 === this.config.Ts.Keyword.Null ? type$1 : contentType || this.schemaUtils.getSchemaType(this.schema)
1258
+ content: type === this.config.Ts.Keyword.Null ? type : contentType || this.schemaUtils.getSchemaType(this.schema)
1366
1259
  };
1367
1260
  }
1368
1261
  };
@@ -1374,8 +1267,8 @@ var AllOfSchemaParser = class extends MonoSchemaParser {
1374
1267
  const ignoreTypes = [this.config.Ts.Keyword.Any];
1375
1268
  const combined = this.schema.allOf.map((childSchema) => this.schemaParserFabric.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema), null, this.schemaPath));
1376
1269
  const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content));
1377
- const type$1 = this.config.Ts.IntersectionType(filtered);
1378
- return this.schemaUtils.safeAddNullToType(this.schema, type$1);
1270
+ const type = this.config.Ts.IntersectionType(filtered);
1271
+ return this.schemaUtils.safeAddNullToType(this.schema, type);
1379
1272
  }
1380
1273
  };
1381
1274
 
@@ -1386,8 +1279,8 @@ var AnyOfSchemaParser = class extends MonoSchemaParser {
1386
1279
  const ignoreTypes = [this.config.Ts.Keyword.Any];
1387
1280
  const combined = this.schema.anyOf.map((childSchema) => this.schemaParserFabric.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema), null, this.schemaPath));
1388
1281
  const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content));
1389
- const type$1 = this.config.Ts.UnionType(filtered);
1390
- return this.schemaUtils.safeAddNullToType(this.schema, type$1);
1282
+ const type = this.config.Ts.UnionType(filtered);
1283
+ return this.schemaUtils.safeAddNullToType(this.schema, type);
1391
1284
  }
1392
1285
  };
1393
1286
 
@@ -1406,8 +1299,8 @@ var OneOfSchemaParser = class extends MonoSchemaParser {
1406
1299
  const ignoreTypes = [this.config.Ts.Keyword.Any];
1407
1300
  const combined = this.schema.oneOf.map((childSchema) => this.schemaParserFabric.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(this.schema, childSchema), null, this.schemaPath));
1408
1301
  const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content));
1409
- const type$1 = this.config.Ts.UnionType(filtered);
1410
- return this.schemaUtils.safeAddNullToType(this.schema, type$1);
1302
+ const type = this.config.Ts.UnionType(filtered);
1303
+ return this.schemaUtils.safeAddNullToType(this.schema, type);
1411
1304
  }
1412
1305
  };
1413
1306
 
@@ -1576,13 +1469,13 @@ var SchemaUtils = class {
1576
1469
  if (this.config.convertedFromSwagger2) return typeof propertySchema.nullable === this.config.Ts.Keyword.Undefined ? isRequired : !propertySchema.nullable;
1577
1470
  return isRequired;
1578
1471
  };
1579
- isNullMissingInType = (schema, type$1) => {
1472
+ isNullMissingInType = (schema, type) => {
1580
1473
  const { nullable, type: schemaType } = schema || {};
1581
- return (nullable || !!lodash.default.get(schema, "x-nullable") || schemaType === this.config.Ts.Keyword.Null) && typeof type$1 === "string" && !type$1.includes(` ${this.config.Ts.Keyword.Null}`) && !type$1.includes(`${this.config.Ts.Keyword.Null} `);
1474
+ return (nullable || !!lodash.default.get(schema, "x-nullable") || schemaType === this.config.Ts.Keyword.Null) && typeof type === "string" && !type.includes(` ${this.config.Ts.Keyword.Null}`) && !type.includes(`${this.config.Ts.Keyword.Null} `);
1582
1475
  };
1583
- safeAddNullToType = (schema, type$1) => {
1584
- if (this.isNullMissingInType(schema, type$1)) return this.config.Ts.UnionType([type$1, this.config.Ts.Keyword.Null]);
1585
- return type$1;
1476
+ safeAddNullToType = (schema, type) => {
1477
+ if (this.isNullMissingInType(schema, type)) return this.config.Ts.UnionType([type, this.config.Ts.Keyword.Null]);
1478
+ return type;
1586
1479
  };
1587
1480
  getSchemaPrimitiveType = (rawSchema) => {
1588
1481
  const schema = rawSchema || {};
@@ -1626,7 +1519,7 @@ var SchemaUtils = class {
1626
1519
  return childSchema;
1627
1520
  };
1628
1521
  filterSchemaContents = (contents, filterFn) => {
1629
- return lodash.default.uniq(contents.filter((type$1) => filterFn(type$1)));
1522
+ return lodash.default.uniq(contents.filter((type) => filterFn(type)));
1630
1523
  };
1631
1524
  resolveTypeName = (typeName, { suffixes, resolver, prefixes, shouldReserve = true }) => {
1632
1525
  if (resolver) return this.config.componentTypeNameResolver.resolve([], (reserved) => {
@@ -2515,14 +2408,12 @@ var TemplatesWorker = class {
2515
2408
  const baseTemplatesPath = node_path.resolve(__dirname$2, "../templates/base");
2516
2409
  const defaultTemplatesPath = node_path.resolve(__dirname$2, "../templates/default");
2517
2410
  const modularTemplatesPath = node_path.resolve(__dirname$2, "../templates/modular");
2518
- const originalTemplatesPath = config.modular ? modularTemplatesPath : defaultTemplatesPath;
2519
- const customTemplatesPath = config.templates && node_path.resolve(process.cwd(), config.templates);
2520
2411
  return {
2521
2412
  base: baseTemplatesPath,
2522
2413
  default: defaultTemplatesPath,
2523
2414
  modular: modularTemplatesPath,
2524
- original: originalTemplatesPath,
2525
- custom: customTemplatesPath
2415
+ original: config.modular ? modularTemplatesPath : defaultTemplatesPath,
2416
+ custom: config.templates && node_path.resolve(process.cwd(), config.templates)
2526
2417
  };
2527
2418
  };
2528
2419
  cropExtension = (path$1) => this.config.templateExtensions.reduce((path$2, ext) => path$2.endsWith(ext) ? path$2.replace(ext, "") : path$2, path$1);
@@ -2829,8 +2720,8 @@ var CodeGenProcess = class {
2829
2720
  consola.consola.debug(`path ${this.config.output} is not exist. creating dir by this path`);
2830
2721
  this.fileSystem.createDir(this.config.output);
2831
2722
  }
2832
- const files$1 = await this.generateOutputFiles({ configuration });
2833
- if (this.fileSystem.pathIsDir(this.config.output)) for (const file of files$1) {
2723
+ const files = await this.generateOutputFiles({ configuration });
2724
+ if (this.fileSystem.pathIsDir(this.config.output)) for (const file of files) {
2834
2725
  this.fileSystem.createFile({
2835
2726
  path: this.config.output,
2836
2727
  fileName: `${file.fileName}${file.fileExtension}`,
@@ -2840,7 +2731,7 @@ var CodeGenProcess = class {
2840
2731
  consola.consola.success("api file", `"${file.fileName}${file.fileExtension}"`, `created in ${this.config.output}`);
2841
2732
  }
2842
2733
  return {
2843
- files: files$1,
2734
+ files,
2844
2735
  configuration,
2845
2736
  getTemplate: this.templatesWorker.getTemplate,
2846
2737
  renderTemplate: this.templatesWorker.renderTemplate,
@@ -3235,6 +3126,12 @@ Object.defineProperty(exports, 'constants_exports', {
3235
3126
  return constants_exports;
3236
3127
  }
3237
3128
  });
3129
+ Object.defineProperty(exports, 'description', {
3130
+ enumerable: true,
3131
+ get: function () {
3132
+ return description;
3133
+ }
3134
+ });
3238
3135
  Object.defineProperty(exports, 'generateApi', {
3239
3136
  enumerable: true,
3240
3137
  get: function () {
@@ -3247,10 +3144,16 @@ Object.defineProperty(exports, 'generateTemplates', {
3247
3144
  return generateTemplates;
3248
3145
  }
3249
3146
  });
3250
- Object.defineProperty(exports, 'package_default', {
3147
+ Object.defineProperty(exports, 'name', {
3148
+ enumerable: true,
3149
+ get: function () {
3150
+ return name;
3151
+ }
3152
+ });
3153
+ Object.defineProperty(exports, 'version', {
3251
3154
  enumerable: true,
3252
3155
  get: function () {
3253
- return package_default;
3156
+ return version;
3254
3157
  }
3255
3158
  });
3256
- //# sourceMappingURL=src-CgtuxwSo.cjs.map
3159
+ //# sourceMappingURL=src-DWf638kx.cjs.map