echoapi-converter 0.0.65 → 0.0.66
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 +43 -34
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1139,8 +1139,17 @@ const handlePathItemRequestBody = (body, pathItem, modelsObj) => {
|
|
|
1139
1139
|
(pathItem === null || pathItem === void 0 ? void 0 : pathItem.requestBody) && delete pathItem.requestBody;
|
|
1140
1140
|
}
|
|
1141
1141
|
};
|
|
1142
|
+
const getUserShowName = (data) => {
|
|
1143
|
+
if (lodash.isString(data === null || data === void 0 ? void 0 : data.alias_name) && (data === null || data === void 0 ? void 0 : data.alias_name.length) > 0) {
|
|
1144
|
+
return data === null || data === void 0 ? void 0 : data.alias_name;
|
|
1145
|
+
}
|
|
1146
|
+
if (lodash.isString(data === null || data === void 0 ? void 0 : data.nick_name) && (data === null || data === void 0 ? void 0 : data.nick_name.length) > 0) {
|
|
1147
|
+
return data === null || data === void 0 ? void 0 : data.nick_name;
|
|
1148
|
+
}
|
|
1149
|
+
return '';
|
|
1150
|
+
};
|
|
1142
1151
|
const createPathItem = (item, sourceObj, pid, pidName, modelsObj, apiVersion, target_type) => {
|
|
1143
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18
|
|
1152
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
|
|
1144
1153
|
const path = recursiveFolderPath("", sourceObj, pid, pidName);
|
|
1145
1154
|
const pathItem = {
|
|
1146
1155
|
'x-target-id': (item === null || item === void 0 ? void 0 : item.target_id) || '',
|
|
@@ -1159,7 +1168,7 @@ const createPathItem = (item, sourceObj, pid, pidName, modelsObj, apiVersion, ta
|
|
|
1159
1168
|
pathItem['x-updated-at'] = item === null || item === void 0 ? void 0 : item.updated_at;
|
|
1160
1169
|
}
|
|
1161
1170
|
if (lodash.isString((_a = item === null || item === void 0 ? void 0 : item.updated_user) === null || _a === void 0 ? void 0 : _a.nick_name)) {
|
|
1162
|
-
pathItem['x-updated-user-name'] = (
|
|
1171
|
+
pathItem['x-updated-user-name'] = getUserShowName(item === null || item === void 0 ? void 0 : item.updated_user);
|
|
1163
1172
|
}
|
|
1164
1173
|
if (lodash.isPlainObject(item === null || item === void 0 ? void 0 : item.attribute_info) && !lodash.isEmpty(item === null || item === void 0 ? void 0 : item.attribute_info)) {
|
|
1165
1174
|
pathItem['x-attribute-info'] = item === null || item === void 0 ? void 0 : item.attribute_info;
|
|
@@ -1169,16 +1178,16 @@ const createPathItem = (item, sourceObj, pid, pidName, modelsObj, apiVersion, ta
|
|
|
1169
1178
|
}
|
|
1170
1179
|
if (['http', 'sse'].includes(target_type)) {
|
|
1171
1180
|
// 处理 Query 和 Header 参数
|
|
1172
|
-
handlePathItemParameters("query", ((
|
|
1173
|
-
handlePathItemParameters("header", ((
|
|
1174
|
-
handlePathItemParameters("cookie", ((
|
|
1175
|
-
handlePathItemParameters("path", ((
|
|
1181
|
+
handlePathItemParameters("query", ((_c = (_b = item === null || item === void 0 ? void 0 : item.request) === null || _b === void 0 ? void 0 : _b.query) === null || _c === void 0 ? void 0 : _c.parameter) || [], pathItem);
|
|
1182
|
+
handlePathItemParameters("header", ((_e = (_d = item === null || item === void 0 ? void 0 : item.request) === null || _d === void 0 ? void 0 : _d.header) === null || _e === void 0 ? void 0 : _e.parameter) || [], pathItem);
|
|
1183
|
+
handlePathItemParameters("cookie", ((_g = (_f = item === null || item === void 0 ? void 0 : item.request) === null || _f === void 0 ? void 0 : _f.cookie) === null || _g === void 0 ? void 0 : _g.parameter) || [], pathItem);
|
|
1184
|
+
handlePathItemParameters("path", ((_j = (_h = item === null || item === void 0 ? void 0 : item.request) === null || _h === void 0 ? void 0 : _h.restful) === null || _j === void 0 ? void 0 : _j.parameter) || [], pathItem);
|
|
1176
1185
|
// 处理请求体参数(根据 Swagger 版本)
|
|
1177
1186
|
if (apiVersion === "2.0") {
|
|
1178
|
-
handlePathItemBodyParameters(((
|
|
1187
|
+
handlePathItemBodyParameters(((_k = item === null || item === void 0 ? void 0 : item.request) === null || _k === void 0 ? void 0 : _k.body) || {}, pathItem, modelsObj);
|
|
1179
1188
|
}
|
|
1180
1189
|
else {
|
|
1181
|
-
handlePathItemRequestBody(((
|
|
1190
|
+
handlePathItemRequestBody(((_l = item === null || item === void 0 ? void 0 : item.request) === null || _l === void 0 ? void 0 : _l.body) || {}, pathItem, modelsObj);
|
|
1182
1191
|
}
|
|
1183
1192
|
// 添加路径标签
|
|
1184
1193
|
if ((path === null || path === void 0 ? void 0 : path.length) > 0 && !pathItem.tags.includes(path)) {
|
|
@@ -1193,35 +1202,35 @@ const createPathItem = (item, sourceObj, pid, pidName, modelsObj, apiVersion, ta
|
|
|
1193
1202
|
switch (target_type) {
|
|
1194
1203
|
case 'socketio':
|
|
1195
1204
|
pathItem.description = `${pathItem.description}
|
|
1196
|
-
${((
|
|
1197
|
-
enable: ((
|
|
1198
|
-
version: ((
|
|
1199
|
-
path: (
|
|
1205
|
+
${((_m = item === null || item === void 0 ? void 0 : item.config) === null || _m === void 0 ? void 0 : _m.shake_hands_path) ? t('securityConnectionMessage', {
|
|
1206
|
+
enable: ((_o = item === null || item === void 0 ? void 0 : item.config) === null || _o === void 0 ? void 0 : _o.certificate_verification) == -1 ? t('notNeedEnable') : t('needEnable'),
|
|
1207
|
+
version: ((_p = item === null || item === void 0 ? void 0 : item.config) === null || _p === void 0 ? void 0 : _p.socket_version) || 'v4',
|
|
1208
|
+
path: (_q = item === null || item === void 0 ? void 0 : item.config) === null || _q === void 0 ? void 0 : _q.shake_hands_path
|
|
1200
1209
|
}) : t('securityConnectionMessageNoPath', {
|
|
1201
|
-
enable: ((
|
|
1202
|
-
version: ((
|
|
1210
|
+
enable: ((_r = item === null || item === void 0 ? void 0 : item.config) === null || _r === void 0 ? void 0 : _r.certificate_verification) == -1 ? t('notNeedEnable') : t('needEnable'),
|
|
1211
|
+
version: ((_s = item === null || item === void 0 ? void 0 : item.config) === null || _s === void 0 ? void 0 : _s.socket_version) || 'v4',
|
|
1203
1212
|
})}
|
|
1204
1213
|
`;
|
|
1205
1214
|
break;
|
|
1206
1215
|
case 'websocket2':
|
|
1207
1216
|
pathItem.description = `${pathItem.description}
|
|
1208
1217
|
${t('wsConfigMessage', {
|
|
1209
|
-
enable: ((
|
|
1210
|
-
content: !((
|
|
1218
|
+
enable: ((_t = item === null || item === void 0 ? void 0 : item.config) === null || _t === void 0 ? void 0 : _t.certificate_verification) == -1 ? t('notNeedEnable') : t('needEnable'),
|
|
1219
|
+
content: !((_u = item === null || item === void 0 ? void 0 : item.config) === null || _u === void 0 ? void 0 : _u.information_size) || ((_v = item === null || item === void 0 ? void 0 : item.config) === null || _v === void 0 ? void 0 : _v.information_size) == 0 ? t('unlimited') : `${(_w = item === null || item === void 0 ? void 0 : item.config) === null || _w === void 0 ? void 0 : _w.information_size}M`
|
|
1211
1220
|
})}
|
|
1212
1221
|
`;
|
|
1213
1222
|
break;
|
|
1214
1223
|
}
|
|
1215
1224
|
}
|
|
1216
|
-
handlePathItemParameters("query", ((
|
|
1217
|
-
handlePathItemParameters("header", ((
|
|
1218
|
-
handlePathItemParameters("cookie", ((
|
|
1219
|
-
handlePathItemParameters("path", ((
|
|
1225
|
+
handlePathItemParameters("query", ((_y = (_x = item === null || item === void 0 ? void 0 : item.request) === null || _x === void 0 ? void 0 : _x.query) === null || _y === void 0 ? void 0 : _y.parameter) || [], pathItem);
|
|
1226
|
+
handlePathItemParameters("header", ((_0 = (_z = item === null || item === void 0 ? void 0 : item.request) === null || _z === void 0 ? void 0 : _z.header) === null || _0 === void 0 ? void 0 : _0.parameter) || [], pathItem);
|
|
1227
|
+
handlePathItemParameters("cookie", ((_2 = (_1 = item === null || item === void 0 ? void 0 : item.request) === null || _1 === void 0 ? void 0 : _1.cookie) === null || _2 === void 0 ? void 0 : _2.parameter) || [], pathItem);
|
|
1228
|
+
handlePathItemParameters("path", ((_4 = (_3 = item === null || item === void 0 ? void 0 : item.request) === null || _3 === void 0 ? void 0 : _3.restful) === null || _4 === void 0 ? void 0 : _4.parameter) || [], pathItem);
|
|
1220
1229
|
if (target_type == 'socketio')
|
|
1221
|
-
handlePathItemParameters("event", ((
|
|
1230
|
+
handlePathItemParameters("event", ((_6 = (_5 = item === null || item === void 0 ? void 0 : item.request) === null || _5 === void 0 ? void 0 : _5.event) === null || _6 === void 0 ? void 0 : _6.parameter) || [], pathItem);
|
|
1222
1231
|
// 处理请体
|
|
1223
1232
|
if (target_type == 'graphql') {
|
|
1224
|
-
handleGraphqlRequestBody(((
|
|
1233
|
+
handleGraphqlRequestBody(((_8 = (_7 = item === null || item === void 0 ? void 0 : item.request) === null || _7 === void 0 ? void 0 : _7.body) === null || _8 === void 0 ? void 0 : _8.query_list) || [], ((_10 = (_9 = item === null || item === void 0 ? void 0 : item.request) === null || _9 === void 0 ? void 0 : _9.body) === null || _10 === void 0 ? void 0 : _10.query_schema) || {}, pathItem, modelsObj);
|
|
1225
1234
|
}
|
|
1226
1235
|
else {
|
|
1227
1236
|
handleMessagePathItemrequestBody((item === null || item === void 0 ? void 0 : item.message) || [], pathItem, modelsObj);
|
|
@@ -1233,23 +1242,23 @@ ${t('wsConfigMessage', {
|
|
|
1233
1242
|
}
|
|
1234
1243
|
else if (target_type == 'socket_method') {
|
|
1235
1244
|
// 拼接description
|
|
1236
|
-
const configs = (
|
|
1245
|
+
const configs = (_11 = item === null || item === void 0 ? void 0 : item.request) === null || _11 === void 0 ? void 0 : _11.configs;
|
|
1237
1246
|
if (lodash.isPlainObject(configs)) {
|
|
1238
|
-
let requestString = `${t('requestEncodingFormat', { format: configs === null || configs === void 0 ? void 0 : configs.charset })} ${lodash.isArray((
|
|
1239
|
-
`\n${t('needAddRequestDataHandleFunction')}\n${(
|
|
1247
|
+
let requestString = `${t('requestEncodingFormat', { format: configs === null || configs === void 0 ? void 0 : configs.charset })} ${lodash.isArray((_12 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _12 === void 0 ? void 0 : _12.request) && ((_13 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _13 === void 0 ? void 0 : _13.request.length) > 0 ?
|
|
1248
|
+
`\n${t('needAddRequestDataHandleFunction')}\n${(_14 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _14 === void 0 ? void 0 : _14.request.map((r, index) => {
|
|
1240
1249
|
let str = getTcpMethodFucString(r);
|
|
1241
1250
|
return str;
|
|
1242
1251
|
})}`
|
|
1243
1252
|
: ''}`;
|
|
1244
|
-
let responseString = lodash.isArray((
|
|
1245
|
-
`${t('needAddResponseDataHandleFunction')}\n${(
|
|
1253
|
+
let responseString = lodash.isArray((_15 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _15 === void 0 ? void 0 : _15.response) && ((_16 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _16 === void 0 ? void 0 : _16.response.length) > 0 ?
|
|
1254
|
+
`${t('needAddResponseDataHandleFunction')}\n${(_17 = configs === null || configs === void 0 ? void 0 : configs.func) === null || _17 === void 0 ? void 0 : _17.response.map((r, index) => {
|
|
1246
1255
|
let str = getTcpMethodFucString(r);
|
|
1247
1256
|
return str;
|
|
1248
1257
|
})}`
|
|
1249
1258
|
: '';
|
|
1250
1259
|
pathItem.description = `${pathItem.description}\n${requestString}\n${responseString}`;
|
|
1251
1260
|
}
|
|
1252
|
-
handleSocketMethodRequestBody(((
|
|
1261
|
+
handleSocketMethodRequestBody(((_18 = item === null || item === void 0 ? void 0 : item.request) === null || _18 === void 0 ? void 0 : _18.body) || {}, pathItem);
|
|
1253
1262
|
// 处理响应
|
|
1254
1263
|
pathItem.responses = handlePathItemResponse((item === null || item === void 0 ? void 0 : item.response) || {}, modelsObj);
|
|
1255
1264
|
// 添加路径标签
|
|
@@ -2047,7 +2056,7 @@ const replaceRef = (schemaObj) => {
|
|
|
2047
2056
|
schemaObj[key] = {
|
|
2048
2057
|
['x-schema-refs']: {
|
|
2049
2058
|
[newIuid]: {
|
|
2050
|
-
ref: (value === null || value === void 0 ? void 0 : value.ref) || (value === null || value === void 0 ? void 0 : value['$ref'])
|
|
2059
|
+
$ref: (value === null || value === void 0 ? void 0 : value.ref) || (value === null || value === void 0 ? void 0 : value['$ref'])
|
|
2051
2060
|
},
|
|
2052
2061
|
},
|
|
2053
2062
|
properties: {},
|
|
@@ -2594,7 +2603,7 @@ class SwaggerToApipost {
|
|
|
2594
2603
|
const Raw = handleBodyJsonSchema(element.schema, raw_parameter);
|
|
2595
2604
|
const originRaw = lodash.isPlainObject(Raw) || Array.isArray(Raw)
|
|
2596
2605
|
? JSON.stringify(Raw)
|
|
2597
|
-
: Raw;
|
|
2606
|
+
: String(Raw);
|
|
2598
2607
|
const Raw_text = this.getBeautifulRaw(originRaw);
|
|
2599
2608
|
let jsonSchema = {};
|
|
2600
2609
|
if (Object.prototype.toString.call((_b = element === null || element === void 0 ? void 0 : element.schema) === null || _b === void 0 ? void 0 : _b["$$ref"]) ===
|
|
@@ -2686,7 +2695,7 @@ class SwaggerToApipost {
|
|
|
2686
2695
|
originRaw = JSON.stringify(Object.assign({}, example));
|
|
2687
2696
|
}
|
|
2688
2697
|
else {
|
|
2689
|
-
originRaw = example;
|
|
2698
|
+
originRaw = String(example);
|
|
2690
2699
|
}
|
|
2691
2700
|
}
|
|
2692
2701
|
catch (error) {
|
|
@@ -2747,7 +2756,7 @@ class SwaggerToApipost {
|
|
|
2747
2756
|
const Raw = handleBodyJsonSchema(bodyData.schema, raw_parameter);
|
|
2748
2757
|
const originRaw = lodash.isPlainObject(Raw) || Array.isArray(Raw)
|
|
2749
2758
|
? JSON.stringify(Raw)
|
|
2750
|
-
: Raw;
|
|
2759
|
+
: String(Raw);
|
|
2751
2760
|
const Raw_text = this.getBeautifulRaw(originRaw);
|
|
2752
2761
|
if (status == 200 || status == 404) {
|
|
2753
2762
|
response.example.push({
|
|
@@ -3078,7 +3087,7 @@ class SwaggerToApipost {
|
|
|
3078
3087
|
const Raw = handleBodyJsonSchema(element.schema, raw_parameter);
|
|
3079
3088
|
const originRaw = lodash.isPlainObject(Raw) || Array.isArray(Raw)
|
|
3080
3089
|
? JSON.stringify(Raw)
|
|
3081
|
-
: Raw;
|
|
3090
|
+
: String(Raw);
|
|
3082
3091
|
const Raw_text = this.getBeautifulRaw(originRaw);
|
|
3083
3092
|
let jsonSchema = {};
|
|
3084
3093
|
if (Object.prototype.toString.call((_b = element === null || element === void 0 ? void 0 : element.schema) === null || _b === void 0 ? void 0 : _b["$$ref"]) ===
|
|
@@ -3148,7 +3157,7 @@ class SwaggerToApipost {
|
|
|
3148
3157
|
const Raw = handleBodyJsonSchema(bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema, raw_parameter);
|
|
3149
3158
|
const originRaw = lodash.isPlainObject(Raw) || Array.isArray(Raw)
|
|
3150
3159
|
? JSON.stringify(Raw)
|
|
3151
|
-
: Raw;
|
|
3160
|
+
: String(Raw);
|
|
3152
3161
|
const Raw_text = this.getBeautifulRaw(originRaw);
|
|
3153
3162
|
let jsonSchema = {};
|
|
3154
3163
|
if (Object.prototype.toString.call((_c = bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema) === null || _c === void 0 ? void 0 : _c["$$ref"]) ===
|