echoapi-converter 0.0.4 → 0.0.6
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 +23 -20
- 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];
|
|
@@ -1618,7 +1618,7 @@ class SwaggerToApipost {
|
|
|
1618
1618
|
is_default: 1,
|
|
1619
1619
|
mock: '',
|
|
1620
1620
|
schema: jsonSchema,
|
|
1621
|
-
|
|
1621
|
+
verify_type: 'schema',
|
|
1622
1622
|
},
|
|
1623
1623
|
});
|
|
1624
1624
|
}
|
|
@@ -1634,7 +1634,7 @@ class SwaggerToApipost {
|
|
|
1634
1634
|
is_default: -1,
|
|
1635
1635
|
mock: '',
|
|
1636
1636
|
schema: jsonSchema,
|
|
1637
|
-
|
|
1637
|
+
verify_type: 'schema',
|
|
1638
1638
|
},
|
|
1639
1639
|
});
|
|
1640
1640
|
}
|
|
@@ -1652,7 +1652,7 @@ class SwaggerToApipost {
|
|
|
1652
1652
|
is_default: -1,
|
|
1653
1653
|
mock: '',
|
|
1654
1654
|
schema: jsonSchema,
|
|
1655
|
-
|
|
1655
|
+
verify_type: 'schema',
|
|
1656
1656
|
},
|
|
1657
1657
|
});
|
|
1658
1658
|
}
|
|
@@ -1699,7 +1699,7 @@ class SwaggerToApipost {
|
|
|
1699
1699
|
is_default: status == 200 ? 1 : -1,
|
|
1700
1700
|
mock: '',
|
|
1701
1701
|
schema: jsonSchema,
|
|
1702
|
-
|
|
1702
|
+
verify_type: 'schema',
|
|
1703
1703
|
},
|
|
1704
1704
|
});
|
|
1705
1705
|
}
|
|
@@ -1725,7 +1725,7 @@ class SwaggerToApipost {
|
|
|
1725
1725
|
is_default: -1,
|
|
1726
1726
|
mock: '',
|
|
1727
1727
|
schema: jsonSchema,
|
|
1728
|
-
|
|
1728
|
+
verify_type: 'schema',
|
|
1729
1729
|
},
|
|
1730
1730
|
});
|
|
1731
1731
|
}
|
|
@@ -1748,7 +1748,7 @@ class SwaggerToApipost {
|
|
|
1748
1748
|
is_default: status == 200 ? 1 : -1,
|
|
1749
1749
|
mock: '',
|
|
1750
1750
|
schema: jsonSchema,
|
|
1751
|
-
|
|
1751
|
+
verify_type: 'schema',
|
|
1752
1752
|
},
|
|
1753
1753
|
});
|
|
1754
1754
|
}
|
|
@@ -1766,7 +1766,7 @@ class SwaggerToApipost {
|
|
|
1766
1766
|
is_default: -1,
|
|
1767
1767
|
mock: '',
|
|
1768
1768
|
schema: jsonSchema,
|
|
1769
|
-
|
|
1769
|
+
verify_type: 'schema',
|
|
1770
1770
|
},
|
|
1771
1771
|
});
|
|
1772
1772
|
}
|
|
@@ -1786,7 +1786,7 @@ class SwaggerToApipost {
|
|
|
1786
1786
|
is_default: -1,
|
|
1787
1787
|
mock: '',
|
|
1788
1788
|
schema: { type: 'object', properties: {} },
|
|
1789
|
-
|
|
1789
|
+
verify_type: 'schema'
|
|
1790
1790
|
},
|
|
1791
1791
|
});
|
|
1792
1792
|
}
|
|
@@ -2055,7 +2055,7 @@ class SwaggerToApipost {
|
|
|
2055
2055
|
is_default: 1,
|
|
2056
2056
|
mock: '',
|
|
2057
2057
|
schema: jsonSchema,
|
|
2058
|
-
|
|
2058
|
+
verify_type: 'schema',
|
|
2059
2059
|
},
|
|
2060
2060
|
});
|
|
2061
2061
|
}
|
|
@@ -2071,7 +2071,7 @@ class SwaggerToApipost {
|
|
|
2071
2071
|
is_default: -1,
|
|
2072
2072
|
mock: '',
|
|
2073
2073
|
schema: jsonSchema,
|
|
2074
|
-
|
|
2074
|
+
verify_type: 'schema',
|
|
2075
2075
|
},
|
|
2076
2076
|
});
|
|
2077
2077
|
}
|
|
@@ -2089,7 +2089,7 @@ class SwaggerToApipost {
|
|
|
2089
2089
|
is_default: -1,
|
|
2090
2090
|
mock: '',
|
|
2091
2091
|
schema: jsonSchema,
|
|
2092
|
-
|
|
2092
|
+
verify_type: 'schema',
|
|
2093
2093
|
},
|
|
2094
2094
|
});
|
|
2095
2095
|
}
|
|
@@ -2121,7 +2121,7 @@ class SwaggerToApipost {
|
|
|
2121
2121
|
is_default: 1,
|
|
2122
2122
|
mock: '',
|
|
2123
2123
|
schema: jsonSchema,
|
|
2124
|
-
|
|
2124
|
+
verify_type: 'schema',
|
|
2125
2125
|
},
|
|
2126
2126
|
});
|
|
2127
2127
|
}
|
|
@@ -2137,7 +2137,7 @@ class SwaggerToApipost {
|
|
|
2137
2137
|
is_default: -1,
|
|
2138
2138
|
mock: '',
|
|
2139
2139
|
schema: jsonSchema,
|
|
2140
|
-
|
|
2140
|
+
verify_type: 'schema',
|
|
2141
2141
|
},
|
|
2142
2142
|
});
|
|
2143
2143
|
}
|
|
@@ -2155,7 +2155,7 @@ class SwaggerToApipost {
|
|
|
2155
2155
|
is_default: -1,
|
|
2156
2156
|
mock: '',
|
|
2157
2157
|
schema: jsonSchema,
|
|
2158
|
-
|
|
2158
|
+
verify_type: 'schema',
|
|
2159
2159
|
},
|
|
2160
2160
|
});
|
|
2161
2161
|
}
|
|
@@ -2181,7 +2181,7 @@ class SwaggerToApipost {
|
|
|
2181
2181
|
is_default: -1,
|
|
2182
2182
|
mock: '',
|
|
2183
2183
|
schema: { type: 'object', properties: {} },
|
|
2184
|
-
|
|
2184
|
+
verify_type: 'schema',
|
|
2185
2185
|
},
|
|
2186
2186
|
});
|
|
2187
2187
|
}
|
|
@@ -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,
|