echoapi-converter 0.0.4 → 0.0.5
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.
- package/dist/index.js +8 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -514,7 +514,7 @@ const createUrl = (_url) => {
|
|
|
514
514
|
return urls;
|
|
515
515
|
};
|
|
516
516
|
// 根据url生成新的restful数组
|
|
517
|
-
const genRestfulByUrl = (url, oldParameter) => {
|
|
517
|
+
const genRestfulByUrl = (url, oldParameter, key = 'key') => {
|
|
518
518
|
const restfulList = [];
|
|
519
519
|
// 自动拼接url http://
|
|
520
520
|
if (!isURL(url)) {
|
|
@@ -526,7 +526,7 @@ const genRestfulByUrl = (url, oldParameter) => {
|
|
|
526
526
|
if (pathsItem.substring(0, 1) === ':' && pathsItem.length > 1) {
|
|
527
527
|
let obj = null;
|
|
528
528
|
const oldIndex = lodash.findIndex(oldParameter, {
|
|
529
|
-
key: pathsItem.substring(1, pathsItem.length),
|
|
529
|
+
[key]: pathsItem.substring(1, pathsItem.length),
|
|
530
530
|
});
|
|
531
531
|
if (oldIndex !== -1) {
|
|
532
532
|
obj = oldParameter[oldIndex];
|
|
@@ -551,7 +551,7 @@ const genRestfulByUrl = (url, oldParameter) => {
|
|
|
551
551
|
matchesItem = matchesItem.replace(/^{|}$/g, '');
|
|
552
552
|
let obj = null;
|
|
553
553
|
const oldIndex = lodash.findIndex(oldParameter, {
|
|
554
|
-
key: matchesItem,
|
|
554
|
+
[key]: matchesItem,
|
|
555
555
|
});
|
|
556
556
|
if (oldIndex !== -1) {
|
|
557
557
|
obj = oldParameter[oldIndex];
|
|
@@ -3982,6 +3982,7 @@ class InsomniaToApipost {
|
|
|
3982
3982
|
request.auth['kv'] = {
|
|
3983
3983
|
key: (authentication === null || authentication === void 0 ? void 0 : authentication.key) || '',
|
|
3984
3984
|
value: (authentication === null || authentication === void 0 ? void 0 : authentication.value) || '',
|
|
3985
|
+
in: (authentication === null || authentication === void 0 ? void 0 : authentication.addTo) === 'queryParams' ? 'query' : 'header',
|
|
3985
3986
|
};
|
|
3986
3987
|
}
|
|
3987
3988
|
else if ((authentication === null || authentication === void 0 ? void 0 : authentication.type) === 'basic') {
|
|
@@ -4027,6 +4028,8 @@ class InsomniaToApipost {
|
|
|
4027
4028
|
parameter: this.completionParameter(item === null || item === void 0 ? void 0 : item.parameters),
|
|
4028
4029
|
}, cookie: {
|
|
4029
4030
|
parameter: [],
|
|
4031
|
+
}, restful: {
|
|
4032
|
+
parameter: genRestfulByUrl((item === null || item === void 0 ? void 0 : item.url) || '', item === null || item === void 0 ? void 0 : item.pathParameters, 'name')
|
|
4030
4033
|
} }, request);
|
|
4031
4034
|
}
|
|
4032
4035
|
completionWsRequest(item, resources) {
|
|
@@ -4441,7 +4444,7 @@ class PostmanToApipost {
|
|
|
4441
4444
|
}, binary: {} }, params);
|
|
4442
4445
|
}
|
|
4443
4446
|
completionApiRequest(item, { request, auth }) {
|
|
4444
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
4447
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
4445
4448
|
const prerequest = (_a = item === null || item === void 0 ? void 0 : item.event) === null || _a === void 0 ? void 0 : _a.find((e) => (e === null || e === void 0 ? void 0 : e.listen) === 'prerequest');
|
|
4446
4449
|
const test = (_b = item === null || item === void 0 ? void 0 : item.event) === null || _b === void 0 ? void 0 : _b.find((e) => (e === null || e === void 0 ? void 0 : e.listen) === 'test');
|
|
4447
4450
|
const pre_tasks = prerequest
|
|
@@ -4469,7 +4472,7 @@ class PostmanToApipost {
|
|
|
4469
4472
|
const queryParameter = this.completionApiRequestParameter((_j = request === null || request === void 0 ? void 0 : request.url) === null || _j === void 0 ? void 0 : _j.query);
|
|
4470
4473
|
const headerParameter = this.completionApiRequestParameter(request === null || request === void 0 ? void 0 : request.header);
|
|
4471
4474
|
const body = this.completionApiRequestBody(request === null || request === void 0 ? void 0 : request.body);
|
|
4472
|
-
const restfulParameter = genRestfulByUrl(`${((_k = request === null || request === void 0 ? void 0 : request.url) === null || _k === void 0 ? void 0 : _k.raw) || ''}`,
|
|
4475
|
+
const restfulParameter = genRestfulByUrl(`${((_k = request === null || request === void 0 ? void 0 : request.url) === null || _k === void 0 ? void 0 : _k.raw) || ''}`, (_l = request === null || request === void 0 ? void 0 : request.url) === null || _l === void 0 ? void 0 : _l.variable);
|
|
4473
4476
|
return {
|
|
4474
4477
|
auth: this.completionApiRequestAuth(auth),
|
|
4475
4478
|
body,
|