echoapi-converter 0.0.42 → 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 +44 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3880,16 +3880,32 @@ 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',
3892
3905
  description: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.description) || '',
3906
+ protocolProfileBehavior: {
3907
+ disableBodyPruning: true // 禁止get请求把body丢弃
3908
+ },
3893
3909
  request: {
3894
3910
  method: (targetItem === null || targetItem === void 0 ? void 0 : targetItem.method) || 'GET',
3895
3911
  header: getPostmanHeader((_b = (_a = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _a === void 0 ? void 0 : _a.header) === null || _b === void 0 ? void 0 : _b.parameter),
@@ -3957,12 +3973,12 @@ const array2PostmanTree = (items, idName = 'id', pidName = 'pid') => {
3957
3973
  };
3958
3974
  }
3959
3975
  if ((target === null || target === void 0 ? void 0 : target.target_type) == 'folder') {
3960
- 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,
3961
3977
  // name: target?.name || '',
3962
3978
  item: itemMap[id]['item'] });
3963
3979
  }
3964
3980
  else {
3965
- 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 });
3966
3982
  }
3967
3983
  const treeItem = itemMap[id];
3968
3984
  if (pid == 0 || pid == undefined) {
@@ -3975,8 +3991,10 @@ const array2PostmanTree = (items, idName = 'id', pidName = 'pid') => {
3975
3991
  };
3976
3992
  }
3977
3993
  itemMap[pid].item.push(treeItem);
3994
+ itemMap[pid].item.sort((a, b) => (a === null || a === void 0 ? void 0 : a.sort) - b.sort);
3978
3995
  }
3979
3996
  }
3997
+ result.sort((a, b) => (a === null || a === void 0 ? void 0 : a.sort) - b.sort);
3980
3998
  return result;
3981
3999
  }
3982
4000
  catch (error) {
@@ -3988,6 +4006,10 @@ const getPostmanAuth = (auth) => {
3988
4006
  if (lodash.isPlainObject(auth)) {
3989
4007
  const { type } = auth;
3990
4008
  switch (type) {
4009
+ case 'noauth':
4010
+ return {
4011
+ type: 'noauth'
4012
+ };
3991
4013
  case 'basic':
3992
4014
  return {
3993
4015
  type: "basic",
@@ -5721,6 +5743,7 @@ class PostmanToApipost {
5721
5743
  return [];
5722
5744
  }
5723
5745
  completionApiRequestBody(body) {
5746
+ var _a, _b;
5724
5747
  const params = {};
5725
5748
  if (body) {
5726
5749
  if ((body === null || body === void 0 ? void 0 : body.mode) === "formdata") {
@@ -5740,6 +5763,23 @@ class PostmanToApipost {
5740
5763
  }
5741
5764
  else if ((body === null || body === void 0 ? void 0 : body.mode) === "raw") {
5742
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
+ }
5743
5783
  params["raw"] = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? getBeautifulRaw(body === null || body === void 0 ? void 0 : body.raw) : "";
5744
5784
  }
5745
5785
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoapi-converter",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "description": "echoapi to swagger",
5
5
  "main": "dist/index.js",
6
6
  "files": [