yapi-apifox-to-typescript 4.1.2 → 4.2.0

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.
@@ -251,31 +251,44 @@ export var Generator = /*#__PURE__*/function () {
251
251
  apifoxInstance = null;
252
252
 
253
253
  if (!(serverConfig.serverType === 'apifox')) {
254
- _context8.next = 8;
254
+ _context8.next = 10;
255
255
  break;
256
256
  }
257
257
 
258
+ if (projectConfig.projectId) {
259
+ _context8.next = 4;
260
+ break;
261
+ }
262
+
263
+ throw new Error('projectId is required when serverType is apifox');
264
+
265
+ case 4:
258
266
  apifoxInstance = new ApifoxToYApiData({
259
267
  token: projectConfig.token,
260
- categories: projectConfig.categories
268
+ projectId: projectConfig.projectId,
269
+ categories: projectConfig.categories,
270
+ serverUrl: serverConfig.serverUrl,
271
+ addFoldersToTags: projectConfig.addFoldersToTags,
272
+ oasVersion: projectConfig.oasVersion,
273
+ exportFormat: projectConfig.exportFormat
261
274
  });
262
- _context8.next = 5;
275
+ _context8.next = 7;
263
276
  return apifoxInstance.getProjectInfo();
264
277
 
265
- case 5:
278
+ case 7:
266
279
  projectInfo = _context8.sent;
267
- _context8.next = 11;
280
+ _context8.next = 13;
268
281
  break;
269
282
 
270
- case 8:
271
- _context8.next = 10;
283
+ case 10:
284
+ _context8.next = 12;
272
285
  return _this3.fetchProjectInfo(_extends({}, serverConfig, projectConfig));
273
286
 
274
- case 10:
287
+ case 12:
275
288
  projectInfo = _context8.sent;
276
289
 
277
- case 11:
278
- _context8.next = 13;
290
+ case 13:
291
+ _context8.next = 15;
279
292
  return Promise.all(projectConfig.categories.map( /*#__PURE__*/function () {
280
293
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(categoryConfig, categoryIndex) {
281
294
  var categoryIds, codes, _iterator, _step, _outputFileList$group, groupedCodes;
@@ -463,7 +476,7 @@ export var Generator = /*#__PURE__*/function () {
463
476
  };
464
477
  }()));
465
478
 
466
- case 13:
479
+ case 15:
467
480
  case "end":
468
481
  return _context8.stop();
469
482
  }
@@ -489,6 +489,32 @@ export declare interface ProjectConfig extends SharedConfig {
489
489
  * @example 'e02a47122259d0c1973a9ff81cabb30685d64abc72f39edaa1ac6b6a792a647d'
490
490
  */
491
491
  token: string | string[];
492
+ /**
493
+ * 项目ID(Apifox专用)。
494
+ *
495
+ * 获取方式:打开项目 --> 项目设置 --> 基本信息 --> 项目ID。
496
+ *
497
+ * @example 5590448
498
+ */
499
+ projectId?: number;
500
+ /**
501
+ * 是否将文件夹添加为标签(Apifox专用)。
502
+ *
503
+ * @default true
504
+ */
505
+ addFoldersToTags?: boolean;
506
+ /**
507
+ * OpenAPI 版本(Apifox专用)。
508
+ *
509
+ * @default '3.0'
510
+ */
511
+ oasVersion?: string;
512
+ /**
513
+ * 导出格式(Apifox专用)。
514
+ *
515
+ * @default 'JSON'
516
+ */
517
+ exportFormat?: 'JSON' | 'YAML';
492
518
  /**
493
519
  * 分类列表。
494
520
  */
package/lib/esm/utils.js CHANGED
@@ -742,6 +742,10 @@ export var getFilteredCat = function getFilteredCat(cat, cats, isApifox) {
742
742
  return c._id === id;
743
743
  });
744
744
  });
745
+ } else {
746
+ categoryIds = categoryIds.filter(function (id) {
747
+ return id !== 0;
748
+ });
745
749
  } // 顺序化
746
750
 
747
751
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yapi-apifox-to-typescript",
3
- "version": "4.1.2",
3
+ "version": "4.2.0",
4
4
  "description": "根据 YApi 或 Apifox 的接口定义生成 TypeScript/JavaScript 的接口类型及其请求函数代码。",
5
5
  "keywords": [
6
6
  "yapi",