echoapi-converter 0.0.6 → 0.0.8
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.d.ts +1 -0
- package/dist/index.js +42 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -634,6 +634,28 @@ const yapiGenRestfulByUrl = (url, oldParameter) => {
|
|
|
634
634
|
catch (error) { }
|
|
635
635
|
return restfulList;
|
|
636
636
|
};
|
|
637
|
+
const fixUrlPath = (url) => {
|
|
638
|
+
try {
|
|
639
|
+
const index = url.indexOf('://');
|
|
640
|
+
let path;
|
|
641
|
+
let protocolAndDomain = '';
|
|
642
|
+
if (index === -1) {
|
|
643
|
+
path = url;
|
|
644
|
+
}
|
|
645
|
+
else {
|
|
646
|
+
// 分开协议和路径部分
|
|
647
|
+
protocolAndDomain = url.slice(0, index + 3);
|
|
648
|
+
path = url.slice(index + 3);
|
|
649
|
+
}
|
|
650
|
+
// 修正路径中的 '//'
|
|
651
|
+
const fixedPath = path.replace(/\/\/+/g, '/');
|
|
652
|
+
// 拼接返回
|
|
653
|
+
return `${protocolAndDomain}${fixedPath}`;
|
|
654
|
+
}
|
|
655
|
+
catch (err) {
|
|
656
|
+
return url;
|
|
657
|
+
}
|
|
658
|
+
};
|
|
637
659
|
|
|
638
660
|
class ApipostToSwagger {
|
|
639
661
|
constructor() {
|
|
@@ -1844,6 +1866,7 @@ class SwaggerToApipost {
|
|
|
1844
1866
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1845
1867
|
let url = path;
|
|
1846
1868
|
url = decodeURI(this.basePath + url);
|
|
1869
|
+
url = fixUrlPath(url);
|
|
1847
1870
|
for (const method in pathItem) {
|
|
1848
1871
|
const swaggerApi = pathItem[method];
|
|
1849
1872
|
if (Object.prototype.toString.call(swaggerApi) !== '[object Object]')
|
|
@@ -4144,6 +4167,21 @@ class InsomniaToApipost {
|
|
|
4144
4167
|
is_force: -1,
|
|
4145
4168
|
};
|
|
4146
4169
|
}
|
|
4170
|
+
getEnvVarList(data) {
|
|
4171
|
+
if (lodash.isObject(data) && lodash.keys(data).length) {
|
|
4172
|
+
return lodash.keys(data).reduce((pre, key) => {
|
|
4173
|
+
pre[key] = {
|
|
4174
|
+
current_value: lodash.isNil(data === null || data === void 0 ? void 0 : data[key]) ? '' : data === null || data === void 0 ? void 0 : data[key],
|
|
4175
|
+
description: '',
|
|
4176
|
+
key,
|
|
4177
|
+
value: lodash.isNil(data === null || data === void 0 ? void 0 : data[key]) ? '' : data === null || data === void 0 ? void 0 : data[key],
|
|
4178
|
+
};
|
|
4179
|
+
return pre;
|
|
4180
|
+
}, {});
|
|
4181
|
+
}
|
|
4182
|
+
return {};
|
|
4183
|
+
}
|
|
4184
|
+
;
|
|
4147
4185
|
completionApis(resources) {
|
|
4148
4186
|
return resources === null || resources === void 0 ? void 0 : resources.reduce((pre, item) => {
|
|
4149
4187
|
if ((item === null || item === void 0 ? void 0 : item._type) === 'request_group' && lodash.has(this.foldersMap, item === null || item === void 0 ? void 0 : item._id)) {
|
|
@@ -4171,14 +4209,14 @@ class InsomniaToApipost {
|
|
|
4171
4209
|
const wsTarget = this.completionWsTarget(item, resources);
|
|
4172
4210
|
pre.push(wsTarget);
|
|
4173
4211
|
}
|
|
4174
|
-
if ((item === null || item === void 0 ? void 0 : item._type) === 'environment') {
|
|
4212
|
+
if ((item === null || item === void 0 ? void 0 : item._type) === 'environment' && (item === null || item === void 0 ? void 0 : item.name)) {
|
|
4175
4213
|
this.envs = this.envs.concat([
|
|
4176
4214
|
{
|
|
4177
4215
|
env_id: ATools.snowflakeId(),
|
|
4178
4216
|
name: item === null || item === void 0 ? void 0 : item.name,
|
|
4179
|
-
is_private: -1,
|
|
4180
|
-
server_list:
|
|
4181
|
-
env_var_list:
|
|
4217
|
+
is_private: (item === null || item === void 0 ? void 0 : item.isPrivate) ? 1 : -1,
|
|
4218
|
+
server_list: [],
|
|
4219
|
+
env_var_list: this.getEnvVarList(item === null || item === void 0 ? void 0 : item.data),
|
|
4182
4220
|
},
|
|
4183
4221
|
]);
|
|
4184
4222
|
}
|