echoapi-converter 0.0.47 → 0.0.49

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 +18 -16
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -730,14 +730,14 @@ const handlePathItemRequestBody = (body, pathItem, modelsObj) => {
730
730
  }
731
731
  };
732
732
  const createPathItem = (item, sourceObj, pid, pidName, modelsObj, apiVersion, target_type) => {
733
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
733
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
734
734
  const path = recursiveFolderPath("", sourceObj, pid, pidName);
735
735
  const pathItem = {
736
736
  'x-target-id': (item === null || item === void 0 ? void 0 : item.target_id) || '',
737
737
  'x-protocol': target_type || '',
738
738
  summary: (item === null || item === void 0 ? void 0 : item.name) || "",
739
739
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
740
- tags: (item === null || item === void 0 ? void 0 : item.tags) || [],
740
+ tags: []
741
741
  };
742
742
  if (lodash.isArray(item === null || item === void 0 ? void 0 : item.tags) && (item === null || item === void 0 ? void 0 : item.tags.length) > 0) {
743
743
  pathItem['x-tags'] = item === null || item === void 0 ? void 0 : item.tags;
@@ -762,12 +762,13 @@ const createPathItem = (item, sourceObj, pid, pidName, modelsObj, apiVersion, ta
762
762
  handlePathItemParameters("query", ((_d = (_c = item === null || item === void 0 ? void 0 : item.request) === null || _c === void 0 ? void 0 : _c.query) === null || _d === void 0 ? void 0 : _d.parameter) || [], pathItem);
763
763
  handlePathItemParameters("header", ((_f = (_e = item === null || item === void 0 ? void 0 : item.request) === null || _e === void 0 ? void 0 : _e.header) === null || _f === void 0 ? void 0 : _f.parameter) || [], pathItem);
764
764
  handlePathItemParameters("cookie", ((_h = (_g = item === null || item === void 0 ? void 0 : item.request) === null || _g === void 0 ? void 0 : _g.cookie) === null || _h === void 0 ? void 0 : _h.parameter) || [], pathItem);
765
+ handlePathItemParameters("path", ((_k = (_j = item === null || item === void 0 ? void 0 : item.request) === null || _j === void 0 ? void 0 : _j.restful) === null || _k === void 0 ? void 0 : _k.parameter) || [], pathItem);
765
766
  // 处理请求体参数(根据 Swagger 版本)
766
767
  if (apiVersion === "2.0") {
767
- handlePathItemBodyParameters(((_j = item === null || item === void 0 ? void 0 : item.request) === null || _j === void 0 ? void 0 : _j.body) || {}, pathItem, modelsObj);
768
+ handlePathItemBodyParameters(((_l = item === null || item === void 0 ? void 0 : item.request) === null || _l === void 0 ? void 0 : _l.body) || {}, pathItem, modelsObj);
768
769
  }
769
770
  else {
770
- handlePathItemRequestBody(((_k = item === null || item === void 0 ? void 0 : item.request) === null || _k === void 0 ? void 0 : _k.body) || {}, pathItem, modelsObj);
771
+ handlePathItemRequestBody(((_m = item === null || item === void 0 ? void 0 : item.request) === null || _m === void 0 ? void 0 : _m.body) || {}, pathItem, modelsObj);
771
772
  }
772
773
  // 添加路径标签
773
774
  if ((path === null || path === void 0 ? void 0 : path.length) > 0 && !pathItem.tags.includes(path)) {
@@ -782,22 +783,23 @@ const createPathItem = (item, sourceObj, pid, pidName, modelsObj, apiVersion, ta
782
783
  switch (target_type) {
783
784
  case 'socketio':
784
785
  pathItem.description = `${pathItem.description}
785
- Over a secure connection,${((_l = item === null || item === void 0 ? void 0 : item.config) === null || _l === void 0 ? void 0 : _l.certificate_verification) == -1 ? 'Do not enable server certificate verification.' : 'Enable server certificate verification'},And use the client version ${((_m = item === null || item === void 0 ? void 0 : item.config) === null || _m === void 0 ? void 0 : _m.socket_version) || 'v4'}And the specified handshake path ${((_o = item === null || item === void 0 ? void 0 : item.config) === null || _o === void 0 ? void 0 : _o.shake_hands_path) || '/socket.io'} make a connection.`;
786
+ Over a secure connection,${((_o = item === null || item === void 0 ? void 0 : item.config) === null || _o === void 0 ? void 0 : _o.certificate_verification) == -1 ? 'Do not enable server certificate verification.' : 'Enable server certificate verification'},And use the client version ${((_p = item === null || item === void 0 ? void 0 : item.config) === null || _p === void 0 ? void 0 : _p.socket_version) || 'v4'}And the specified handshake path ${((_q = item === null || item === void 0 ? void 0 : item.config) === null || _q === void 0 ? void 0 : _q.shake_hands_path) || '/socket.io'} make a connection.`;
786
787
  break;
787
788
  case 'websocket2':
788
789
  pathItem.description = `${pathItem.description}
789
- Over a secure connection,${((_p = item === null || item === void 0 ? void 0 : item.config) === null || _p === void 0 ? void 0 : _p.certificate_verification) == -1 ? 'Do not enable server certificate verification.' : 'Enable server certificate verification'},${((_q = item === null || item === void 0 ? void 0 : item.config) === null || _q === void 0 ? void 0 : _q.information_size) == 0 ? 'And there is no limit to the maximum sent content that can be received。' : `And the maximum sent content allowed to be received is${((_r = item === null || item === void 0 ? void 0 : item.config) === null || _r === void 0 ? void 0 : _r.information_size) || 5}M。`}`;
790
+ Over a secure connection,${((_r = item === null || item === void 0 ? void 0 : item.config) === null || _r === void 0 ? void 0 : _r.certificate_verification) == -1 ? 'Do not enable server certificate verification.' : 'Enable server certificate verification'},${((_s = item === null || item === void 0 ? void 0 : item.config) === null || _s === void 0 ? void 0 : _s.information_size) == 0 ? 'And there is no limit to the maximum sent content that can be received。' : `And the maximum sent content allowed to be received is${((_t = item === null || item === void 0 ? void 0 : item.config) === null || _t === void 0 ? void 0 : _t.information_size) || 5}M。`}`;
790
791
  break;
791
792
  }
792
793
  }
793
- handlePathItemParameters("query", ((_t = (_s = item === null || item === void 0 ? void 0 : item.request) === null || _s === void 0 ? void 0 : _s.query) === null || _t === void 0 ? void 0 : _t.parameter) || [], pathItem);
794
- handlePathItemParameters("header", ((_v = (_u = item === null || item === void 0 ? void 0 : item.request) === null || _u === void 0 ? void 0 : _u.header) === null || _v === void 0 ? void 0 : _v.parameter) || [], pathItem);
795
- handlePathItemParameters("cookie", ((_x = (_w = item === null || item === void 0 ? void 0 : item.request) === null || _w === void 0 ? void 0 : _w.cookie) === null || _x === void 0 ? void 0 : _x.parameter) || [], pathItem);
794
+ handlePathItemParameters("query", ((_v = (_u = item === null || item === void 0 ? void 0 : item.request) === null || _u === void 0 ? void 0 : _u.query) === null || _v === void 0 ? void 0 : _v.parameter) || [], pathItem);
795
+ handlePathItemParameters("header", ((_x = (_w = item === null || item === void 0 ? void 0 : item.request) === null || _w === void 0 ? void 0 : _w.header) === null || _x === void 0 ? void 0 : _x.parameter) || [], pathItem);
796
+ handlePathItemParameters("cookie", ((_z = (_y = item === null || item === void 0 ? void 0 : item.request) === null || _y === void 0 ? void 0 : _y.cookie) === null || _z === void 0 ? void 0 : _z.parameter) || [], pathItem);
797
+ handlePathItemParameters("path", ((_1 = (_0 = item === null || item === void 0 ? void 0 : item.request) === null || _0 === void 0 ? void 0 : _0.restful) === null || _1 === void 0 ? void 0 : _1.parameter) || [], pathItem);
796
798
  if (target_type == 'socketio')
797
- handlePathItemParameters("event", ((_z = (_y = item === null || item === void 0 ? void 0 : item.request) === null || _y === void 0 ? void 0 : _y.event) === null || _z === void 0 ? void 0 : _z.parameter) || [], pathItem);
799
+ handlePathItemParameters("event", ((_3 = (_2 = item === null || item === void 0 ? void 0 : item.request) === null || _2 === void 0 ? void 0 : _2.event) === null || _3 === void 0 ? void 0 : _3.parameter) || [], pathItem);
798
800
  // 处理请体
799
801
  if (target_type == 'graphql') {
800
- handleGraphqlRequestBody(((_1 = (_0 = item === null || item === void 0 ? void 0 : item.request) === null || _0 === void 0 ? void 0 : _0.body) === null || _1 === void 0 ? void 0 : _1.query_list) || [], ((_3 = (_2 = item === null || item === void 0 ? void 0 : item.request) === null || _2 === void 0 ? void 0 : _2.body) === null || _3 === void 0 ? void 0 : _3.query_schema) || {}, pathItem, modelsObj);
802
+ handleGraphqlRequestBody(((_5 = (_4 = item === null || item === void 0 ? void 0 : item.request) === null || _4 === void 0 ? void 0 : _4.body) === null || _5 === void 0 ? void 0 : _5.query_list) || [], ((_7 = (_6 = item === null || item === void 0 ? void 0 : item.request) === null || _6 === void 0 ? void 0 : _6.body) === null || _7 === void 0 ? void 0 : _7.query_schema) || {}, pathItem, modelsObj);
801
803
  }
802
804
  else {
803
805
  handleMessagePathItemrequestBody((item === null || item === void 0 ? void 0 : item.message) || [], pathItem, modelsObj);
@@ -809,10 +811,10 @@ Over a secure connection,${((_p = item === null || item === void 0 ? void 0 :
809
811
  }
810
812
  else if (target_type == 'socket_method') {
811
813
  // 拼接description
812
- const configs = (_4 = item === null || item === void 0 ? void 0 : item.request) === null || _4 === void 0 ? void 0 : _4.configs;
814
+ const configs = (_8 = item === null || item === void 0 ? void 0 : item.request) === null || _8 === void 0 ? void 0 : _8.configs;
813
815
  if (lodash.isPlainObject(configs)) {
814
- let requestString = `The encoding format of the request packet is ${configs === null || configs === void 0 ? void 0 : configs.charset} ${lodash.isArray((_5 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _5 === void 0 ? void 0 : _5.request) && ((_6 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _6 === void 0 ? void 0 : _6.request.length) > 0 ?
815
- (_7 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _7 === void 0 ? void 0 : _7.request.map((r, index) => {
816
+ let requestString = `The encoding format of the request packet is ${configs === null || configs === void 0 ? void 0 : configs.charset} ${lodash.isArray((_9 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _9 === void 0 ? void 0 : _9.request) && ((_10 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _10 === void 0 ? void 0 : _10.request.length) > 0 ?
817
+ (_11 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _11 === void 0 ? void 0 : _11.request.map((r, index) => {
816
818
  var _a;
817
819
  let str = getTcpMethodFucString(r);
818
820
  if (index < ((_a = configs === null || configs === void 0 ? void 0 : configs.func) === null || _a === void 0 ? void 0 : _a.request.length) - 1) {
@@ -820,7 +822,7 @@ Over a secure connection,${((_p = item === null || item === void 0 ? void 0 :
820
822
  }
821
823
  return str;
822
824
  }) : ''}`;
823
- let responseString = lodash.isArray((_8 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _8 === void 0 ? void 0 : _8.response) && ((_9 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _9 === void 0 ? void 0 : _9.response.length) > 0 ? (_10 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _10 === void 0 ? void 0 : _10.response.map((r, index) => {
825
+ let responseString = lodash.isArray((_12 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _12 === void 0 ? void 0 : _12.response) && ((_13 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _13 === void 0 ? void 0 : _13.response.length) > 0 ? (_14 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _14 === void 0 ? void 0 : _14.response.map((r, index) => {
824
826
  var _a;
825
827
  let str = getTcpMethodFucString(r);
826
828
  if (index < ((_a = configs === null || configs === void 0 ? void 0 : configs.func) === null || _a === void 0 ? void 0 : _a.request.length) - 1) {
@@ -830,7 +832,7 @@ Over a secure connection,${((_p = item === null || item === void 0 ? void 0 :
830
832
  }) : '';
831
833
  pathItem.description = `${pathItem.description}\n${requestString}\n${responseString}`;
832
834
  }
833
- handleSocketMethodRequestBody(((_11 = item === null || item === void 0 ? void 0 : item.request) === null || _11 === void 0 ? void 0 : _11.body) || {}, pathItem);
835
+ handleSocketMethodRequestBody(((_15 = item === null || item === void 0 ? void 0 : item.request) === null || _15 === void 0 ? void 0 : _15.body) || {}, pathItem);
834
836
  // 处理响应
835
837
  pathItem.responses = handlePathItemResponse((item === null || item === void 0 ? void 0 : item.response) || {}, modelsObj);
836
838
  // 添加路径标签
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoapi-converter",
3
- "version": "0.0.47",
3
+ "version": "0.0.49",
4
4
  "description": "echoapi to swagger",
5
5
  "main": "dist/index.js",
6
6
  "files": [