echoapi-converter 0.0.43 → 0.0.44

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 +41 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3880,12 +3880,25 @@ const completionPostmanTarget = (targetItem) => {
3880
3880
  }
3881
3881
  return [];
3882
3882
  };
3883
- return {
3883
+ const getHostWithPortFromUrl = (urlString) => {
3884
+ try {
3885
+ const url = new URL(urlString);
3886
+ return url.host; // 返回包含端口号的host部分(如果有的话)
3887
+ }
3888
+ catch (error) {
3889
+ return '';
3890
+ }
3891
+ };
3892
+ const urlHost = getHostWithPortFromUrl((targetItem === null || targetItem === void 0 ? void 0 : targetItem.url) || '');
3893
+ const urlObj = {
3884
3894
  raw: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.url) || '',
3885
- host: [(targetItem === null || targetItem === void 0 ? void 0 : targetItem.url) || ''],
3886
3895
  query: getPostmanQuery((_b = (_a = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _a === void 0 ? void 0 : _a.query) === null || _b === void 0 ? void 0 : _b.parameter),
3887
3896
  variable: getPostmanVariable((_d = (_c = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _c === void 0 ? void 0 : _c.restful) === null || _d === void 0 ? void 0 : _d.parameter)
3888
3897
  };
3898
+ if (urlHost) {
3899
+ urlObj.host = [urlHost];
3900
+ }
3901
+ return urlObj;
3889
3902
  };
3890
3903
  const result = {
3891
3904
  name: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.name) || 'New HTTP',
@@ -3960,12 +3973,12 @@ const array2PostmanTree = (items, idName = 'id', pidName = 'pid') => {
3960
3973
  };
3961
3974
  }
3962
3975
  if ((target === null || target === void 0 ? void 0 : target.target_type) == 'folder') {
3963
- itemMap[id] = Object.assign(Object.assign({}, completionPostmanFolder(target)), {
3976
+ itemMap[id] = Object.assign(Object.assign({}, completionPostmanFolder(target)), { sort: target === null || target === void 0 ? void 0 : target.sort,
3964
3977
  // name: target?.name || '',
3965
3978
  item: itemMap[id]['item'] });
3966
3979
  }
3967
3980
  else {
3968
- itemMap[id] = Object.assign({}, completionPostmanTarget(target));
3981
+ itemMap[id] = Object.assign(Object.assign({}, completionPostmanTarget(target)), { sort: target === null || target === void 0 ? void 0 : target.sort });
3969
3982
  }
3970
3983
  const treeItem = itemMap[id];
3971
3984
  if (pid == 0 || pid == undefined) {
@@ -3978,8 +3991,10 @@ const array2PostmanTree = (items, idName = 'id', pidName = 'pid') => {
3978
3991
  };
3979
3992
  }
3980
3993
  itemMap[pid].item.push(treeItem);
3994
+ itemMap[pid].item.sort((a, b) => (a === null || a === void 0 ? void 0 : a.sort) - b.sort);
3981
3995
  }
3982
3996
  }
3997
+ result.sort((a, b) => (a === null || a === void 0 ? void 0 : a.sort) - b.sort);
3983
3998
  return result;
3984
3999
  }
3985
4000
  catch (error) {
@@ -3991,6 +4006,10 @@ const getPostmanAuth = (auth) => {
3991
4006
  if (lodash.isPlainObject(auth)) {
3992
4007
  const { type } = auth;
3993
4008
  switch (type) {
4009
+ case 'noauth':
4010
+ return {
4011
+ type: 'noauth'
4012
+ };
3994
4013
  case 'basic':
3995
4014
  return {
3996
4015
  type: "basic",
@@ -5724,6 +5743,7 @@ class PostmanToApipost {
5724
5743
  return [];
5725
5744
  }
5726
5745
  completionApiRequestBody(body) {
5746
+ var _a, _b;
5727
5747
  const params = {};
5728
5748
  if (body) {
5729
5749
  if ((body === null || body === void 0 ? void 0 : body.mode) === "formdata") {
@@ -5743,6 +5763,23 @@ class PostmanToApipost {
5743
5763
  }
5744
5764
  else if ((body === null || body === void 0 ? void 0 : body.mode) === "raw") {
5745
5765
  params["mode"] = "json";
5766
+ switch ((_b = (_a = body === null || body === void 0 ? void 0 : body.options) === null || _a === void 0 ? void 0 : _a.raw) === null || _b === void 0 ? void 0 : _b.language) {
5767
+ case 'json':
5768
+ params["mode"] = "json";
5769
+ break;
5770
+ case 'xml':
5771
+ params["mode"] = "xml";
5772
+ break;
5773
+ case 'javascript':
5774
+ params["mode"] = "javascript";
5775
+ break;
5776
+ case 'text':
5777
+ params["mode"] = "plain";
5778
+ break;
5779
+ case 'html':
5780
+ params["mode"] = "html";
5781
+ break;
5782
+ }
5746
5783
  params["raw"] = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? getBeautifulRaw(body === null || body === void 0 ? void 0 : body.raw) : "";
5747
5784
  }
5748
5785
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoapi-converter",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "description": "echoapi to swagger",
5
5
  "main": "dist/index.js",
6
6
  "files": [