echoapi-converter 0.0.49 → 0.0.51

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.
Files changed (2) hide show
  1. package/dist/index.js +31 -11
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -616,11 +616,10 @@ const handleSocketMethodRequestBody = (body, pathItem) => {
616
616
  };
617
617
  }
618
618
  else {
619
- let modeStr = MODE_TYPE[mode];
620
- if (modeStr) {
621
- pathItem.requestBody.content[modeStr] = {
622
- 'x-mode': modeStr || '',
623
- schema: {
619
+ if (mode) {
620
+ pathItem.requestBody.content[mode] = {
621
+ 'x-mode': mode || '',
622
+ schema: lodash.isPlainObject(body === null || body === void 0 ? void 0 : body.raw_schema) && !lodash.isEmpty(body === null || body === void 0 ? void 0 : body.raw_schema) ? body === null || body === void 0 ? void 0 : body.raw_schema : {
624
623
  type: "object",
625
624
  },
626
625
  example: (body === null || body === void 0 ? void 0 : body.raw) || "",
@@ -708,11 +707,12 @@ const handlePathItemRequestBody = (body, pathItem, modelsObj) => {
708
707
  schema: {
709
708
  type: "object",
710
709
  properties: parameter.reduce((lastData, item) => {
710
+ var _a;
711
711
  if (lodash.isString(item === null || item === void 0 ? void 0 : item.key) &&
712
712
  item.key.length > 0 &&
713
713
  (!lodash.has(item, "is_checked") || (item === null || item === void 0 ? void 0 : item.is_checked) > 0)) {
714
714
  lastData[item.key] = {
715
- type: "string",
715
+ type: ((_a = item === null || item === void 0 ? void 0 : item.field_type) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || 'string',
716
716
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
717
717
  example: (item === null || item === void 0 ? void 0 : item.value) || "",
718
718
  };
@@ -746,7 +746,7 @@ const createPathItem = (item, sourceObj, pid, pidName, modelsObj, apiVersion, ta
746
746
  pathItem['x-mark-id'] = item === null || item === void 0 ? void 0 : item.mark_id;
747
747
  }
748
748
  if (lodash.isString(item === null || item === void 0 ? void 0 : item.updated_at)) {
749
- pathItem['x-updated-at'] = item === null || item === void 0 ? void 0 : item.tags;
749
+ pathItem['x-updated-at'] = item === null || item === void 0 ? void 0 : item.updated_at;
750
750
  }
751
751
  if (lodash.isString((_a = item === null || item === void 0 ? void 0 : item.updated_user) === null || _a === void 0 ? void 0 : _a.nick_name)) {
752
752
  pathItem['x-updated-user-name'] = (_b = item === null || item === void 0 ? void 0 : item.updated_user) === null || _b === void 0 ? void 0 : _b.nick_name;
@@ -1329,7 +1329,12 @@ class ApipostToSwagger {
1329
1329
  paths[temp_url][targetMethod] = pathItem;
1330
1330
  }
1331
1331
  else if (pathItem.tags.length > 0) {
1332
- paths[temp_url][targetMethod].tags.push(...pathItem.tags);
1332
+ lodash.forEach(pathItem.tags, tag => {
1333
+ if (!paths[temp_url][targetMethod].tags.includes(tag)) {
1334
+ // 排除重复目录
1335
+ paths[temp_url][targetMethod].tags.push(tag);
1336
+ }
1337
+ });
1333
1338
  }
1334
1339
  }
1335
1340
  else if (["folder", "socket"].includes(item.target_type)) {
@@ -1367,7 +1372,12 @@ ${item.description}
1367
1372
  paths[temp_url][targetMethod] = pathItem;
1368
1373
  }
1369
1374
  else if (pathItem.tags.length > 0) {
1370
- paths[temp_url][targetMethod].tags.push(...pathItem.tags);
1375
+ lodash.forEach(pathItem.tags, tag => {
1376
+ if (!paths[temp_url][targetMethod].tags.includes(tag)) {
1377
+ // 排除重复目录
1378
+ paths[temp_url][targetMethod].tags.push(tag);
1379
+ }
1380
+ });
1371
1381
  }
1372
1382
  }
1373
1383
  else if (item.target_type === 'socket_method') {
@@ -1380,7 +1390,12 @@ ${item.description}
1380
1390
  paths[temp_url][targetMethod] = pathItem;
1381
1391
  }
1382
1392
  else if (pathItem.tags.length > 0) {
1383
- paths[temp_url][targetMethod].tags.push(...pathItem.tags);
1393
+ lodash.forEach(pathItem.tags, tag => {
1394
+ if (!paths[temp_url][targetMethod].tags.includes(tag)) {
1395
+ // 排除重复目录
1396
+ paths[temp_url][targetMethod].tags.push(tag);
1397
+ }
1398
+ });
1384
1399
  }
1385
1400
  }
1386
1401
  else if (item.target_type === 'doc') {
@@ -1393,7 +1408,12 @@ ${item.description}
1393
1408
  paths[temp_url][targetMethod] = pathItem;
1394
1409
  }
1395
1410
  else if (pathItem.tags.length > 0) {
1396
- paths[temp_url][targetMethod].tags.push(...pathItem.tags);
1411
+ lodash.forEach(pathItem.tags, tag => {
1412
+ if (!paths[temp_url][targetMethod].tags.includes(tag)) {
1413
+ // 排除重复目录
1414
+ paths[temp_url][targetMethod].tags.push(tag);
1415
+ }
1416
+ });
1397
1417
  }
1398
1418
  }
1399
1419
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoapi-converter",
3
- "version": "0.0.49",
3
+ "version": "0.0.51",
4
4
  "description": "echoapi to swagger",
5
5
  "main": "dist/index.js",
6
6
  "files": [