echoapi-converter 0.0.67 → 0.0.69
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 +588 -401
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -76,6 +76,17 @@ const MODE_TYPE = {
|
|
|
76
76
|
plain: "text/plain",
|
|
77
77
|
html: "text/html",
|
|
78
78
|
};
|
|
79
|
+
const MODE_TYPE2 = {
|
|
80
|
+
"multipart/form-data": "form-data",
|
|
81
|
+
"application/x-www-form-urlencoded": "urlencoded",
|
|
82
|
+
"application/json": "json",
|
|
83
|
+
"application/xml": "xml",
|
|
84
|
+
"application/javascript": "javascript",
|
|
85
|
+
"text/plain": "plain",
|
|
86
|
+
"text/html": "html",
|
|
87
|
+
"fixed_message": 'fixed_message',
|
|
88
|
+
"delimiter_message": 'delimiter_message'
|
|
89
|
+
};
|
|
79
90
|
const DEFAULT_AUTH = {
|
|
80
91
|
type: "inherit",
|
|
81
92
|
kv: { key: "", value: "", in: "header" },
|
|
@@ -1319,7 +1330,7 @@ const transExample = (example) => {
|
|
|
1319
1330
|
return String(example);
|
|
1320
1331
|
return example;
|
|
1321
1332
|
};
|
|
1322
|
-
const getBeautifulRaw = (raw) => {
|
|
1333
|
+
const getBeautifulRaw$1 = (raw) => {
|
|
1323
1334
|
var _a;
|
|
1324
1335
|
try {
|
|
1325
1336
|
if (!raw) {
|
|
@@ -2187,6 +2198,533 @@ const getExampleId = (status) => {
|
|
|
2187
2198
|
return apipostTools.snowflakeId();
|
|
2188
2199
|
}
|
|
2189
2200
|
};
|
|
2201
|
+
const completionParameter = (parameter) => {
|
|
2202
|
+
if (lodash.isArray(parameter)) {
|
|
2203
|
+
return parameter.map((p) => {
|
|
2204
|
+
var _a, _b;
|
|
2205
|
+
return {
|
|
2206
|
+
is_checked: 1, // 是否选择
|
|
2207
|
+
key: (p === null || p === void 0 ? void 0 : p.name) || "", //参数名
|
|
2208
|
+
value: transExample(p === null || p === void 0 ? void 0 : p.example) ||
|
|
2209
|
+
transExample((_a = p === null || p === void 0 ? void 0 : p.schema) === null || _a === void 0 ? void 0 : _a.example) ||
|
|
2210
|
+
transExample(p === null || p === void 0 ? void 0 : p.default) ||
|
|
2211
|
+
"", //参数值
|
|
2212
|
+
not_null: p.required ? 1 : -1, // 是否为空
|
|
2213
|
+
description: anyToString(p === null || p === void 0 ? void 0 : p.description) || "", // 参数描述
|
|
2214
|
+
field_type: getFidldType((_b = p === null || p === void 0 ? void 0 : p.schema) === null || _b === void 0 ? void 0 : _b.type), // 类型
|
|
2215
|
+
param_id: apipostTools.snowflakeId(),
|
|
2216
|
+
schema: (p === null || p === void 0 ? void 0 : p.schema) || {}
|
|
2217
|
+
};
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
return [];
|
|
2221
|
+
};
|
|
2222
|
+
const completionBodyParameter = (properties) => {
|
|
2223
|
+
return lodash.map(properties, (value, key) => {
|
|
2224
|
+
return {
|
|
2225
|
+
is_checked: 1,
|
|
2226
|
+
key: key || "",
|
|
2227
|
+
value: transExample(value === null || value === void 0 ? void 0 : value.example) || "",
|
|
2228
|
+
not_null: (value === null || value === void 0 ? void 0 : value.required) ? 1 : -1,
|
|
2229
|
+
description: anyToString(value === null || value === void 0 ? void 0 : value.description) || "",
|
|
2230
|
+
field_type: lodash.has(value, "type")
|
|
2231
|
+
? value.type.charAt(0).toUpperCase() + value.type.slice(1)
|
|
2232
|
+
: "String",
|
|
2233
|
+
param_id: apipostTools.snowflakeId(),
|
|
2234
|
+
schema: (value === null || value === void 0 ? void 0 : value.schema) || {}
|
|
2235
|
+
};
|
|
2236
|
+
});
|
|
2237
|
+
};
|
|
2238
|
+
const getBeautifulRaw = (raw) => {
|
|
2239
|
+
var _a;
|
|
2240
|
+
try {
|
|
2241
|
+
if (!raw) {
|
|
2242
|
+
return raw;
|
|
2243
|
+
}
|
|
2244
|
+
return (_a = apipostTools.beautifyRaw(raw)) === null || _a === void 0 ? void 0 : _a.value;
|
|
2245
|
+
}
|
|
2246
|
+
catch (err) {
|
|
2247
|
+
return raw;
|
|
2248
|
+
}
|
|
2249
|
+
};
|
|
2250
|
+
const completionBodyRaw = (bodyData) => {
|
|
2251
|
+
let raw = '';
|
|
2252
|
+
if (lodash.has(bodyData, "example")) {
|
|
2253
|
+
let example = bodyData.example;
|
|
2254
|
+
if (typeof example == "object") {
|
|
2255
|
+
example = JSON.stringify(example);
|
|
2256
|
+
}
|
|
2257
|
+
raw = example;
|
|
2258
|
+
}
|
|
2259
|
+
if (lodash.has(bodyData, "schema")) {
|
|
2260
|
+
const raw_parameter = [];
|
|
2261
|
+
const Raw = handleBodyJsonSchema(bodyData.schema, raw_parameter);
|
|
2262
|
+
const Raw_text = lodash.isPlainObject(Raw) || Array.isArray(Raw)
|
|
2263
|
+
? JSON.stringify(Raw)
|
|
2264
|
+
: Raw;
|
|
2265
|
+
raw = raw ? raw : Raw_text;
|
|
2266
|
+
// if (isEmpty(raw)) {
|
|
2267
|
+
// try {
|
|
2268
|
+
// const myMockSchema = new (MockSchema as any)();
|
|
2269
|
+
// const schemaJson = await myMockSchema.mock(bodyData.schema);
|
|
2270
|
+
// raw =
|
|
2271
|
+
// isPlainObject(schemaJson) || Array.isArray(Raw)
|
|
2272
|
+
// ? JSON.stringify(schemaJson)
|
|
2273
|
+
// : schemaJson;
|
|
2274
|
+
// } catch (error) { }
|
|
2275
|
+
// }
|
|
2276
|
+
}
|
|
2277
|
+
if (!lodash.isString(raw)) {
|
|
2278
|
+
raw = JSON.stringify(raw);
|
|
2279
|
+
}
|
|
2280
|
+
return getBeautifulRaw(raw);
|
|
2281
|
+
};
|
|
2282
|
+
const completionBodyRawParameter = (bodyData) => {
|
|
2283
|
+
const raw_parameter = [];
|
|
2284
|
+
handleBodyJsonSchema(bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema, raw_parameter);
|
|
2285
|
+
return raw_parameter;
|
|
2286
|
+
};
|
|
2287
|
+
const completionBody = (swaggerApi) => {
|
|
2288
|
+
var _a, _b;
|
|
2289
|
+
const content = ((_a = swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.requestBody) === null || _a === void 0 ? void 0 : _a.content) || {};
|
|
2290
|
+
const mode = lodash.isPlainObject(content) && !lodash.isEmpty(content) ? Object.keys(content)[0] : "none";
|
|
2291
|
+
const bodyData = (content === null || content === void 0 ? void 0 : content[mode]) || {};
|
|
2292
|
+
const apipostMode = getApipostMode(mode);
|
|
2293
|
+
let properties = {};
|
|
2294
|
+
if (lodash.has(bodyData, "schema")) {
|
|
2295
|
+
const { schema } = bodyData;
|
|
2296
|
+
if ((schema === null || schema === void 0 ? void 0 : schema.type) === "array") {
|
|
2297
|
+
properties = (_b = schema === null || schema === void 0 ? void 0 : schema.items) === null || _b === void 0 ? void 0 : _b.properties;
|
|
2298
|
+
}
|
|
2299
|
+
else {
|
|
2300
|
+
properties = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
2301
|
+
}
|
|
2302
|
+
}
|
|
2303
|
+
return {
|
|
2304
|
+
mode: apipostMode || 'none',
|
|
2305
|
+
parameter: completionBodyParameter(properties),
|
|
2306
|
+
raw: completionBodyRaw(bodyData),
|
|
2307
|
+
raw_parameter: completionBodyRawParameter(bodyData),
|
|
2308
|
+
raw_schema: swaggerSchema2apipostSchema((bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema) || {}), // schema递归
|
|
2309
|
+
binary: null,
|
|
2310
|
+
};
|
|
2311
|
+
};
|
|
2312
|
+
const completionRequestParam = (swaggerApi) => {
|
|
2313
|
+
const parameters = lodash.isArray(swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.parameters) ? swaggerApi.parameters : [];
|
|
2314
|
+
return {
|
|
2315
|
+
header: {
|
|
2316
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'header' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2317
|
+
},
|
|
2318
|
+
query: {
|
|
2319
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'query' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2320
|
+
},
|
|
2321
|
+
restful: {
|
|
2322
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'path' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2323
|
+
},
|
|
2324
|
+
cookie: {
|
|
2325
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'cookie' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2326
|
+
},
|
|
2327
|
+
body: Object.assign({}, completionBody(swaggerApi)),
|
|
2328
|
+
};
|
|
2329
|
+
};
|
|
2330
|
+
const completionResponse = (responses) => {
|
|
2331
|
+
const example = [];
|
|
2332
|
+
if (lodash.isPlainObject(responses)) {
|
|
2333
|
+
Object.keys(responses).forEach((status) => {
|
|
2334
|
+
var _a, _b, _c, _d;
|
|
2335
|
+
const element = responses[status];
|
|
2336
|
+
if ((lodash.has(element, "schema") &&
|
|
2337
|
+
lodash.has(element.schema, "properties") &&
|
|
2338
|
+
JSON.stringify(element.schema.properties) !== "{}") ||
|
|
2339
|
+
((_a = element === null || element === void 0 ? void 0 : element.schema) === null || _a === void 0 ? void 0 : _a.type) === "array") {
|
|
2340
|
+
const raw_parameter = [];
|
|
2341
|
+
const Raw = handleBodyJsonSchema(element.schema, raw_parameter);
|
|
2342
|
+
const originRaw = lodash.isPlainObject(Raw) || Array.isArray(Raw)
|
|
2343
|
+
? JSON.stringify(Raw)
|
|
2344
|
+
: String(Raw);
|
|
2345
|
+
const Raw_text = getBeautifulRaw(originRaw);
|
|
2346
|
+
let jsonSchema = {};
|
|
2347
|
+
if (Object.prototype.toString.call((_b = element === null || element === void 0 ? void 0 : element.schema) === null || _b === void 0 ? void 0 : _b["$$ref"]) ===
|
|
2348
|
+
"[object String]") {
|
|
2349
|
+
jsonSchema = swaggerSchema2apipostSchema(element.schema);
|
|
2350
|
+
}
|
|
2351
|
+
else {
|
|
2352
|
+
jsonSchema = element.schema;
|
|
2353
|
+
}
|
|
2354
|
+
// 成功响应示例
|
|
2355
|
+
if (String(status) == '200') {
|
|
2356
|
+
example.push({
|
|
2357
|
+
example_id: "1",
|
|
2358
|
+
raw: Raw_text,
|
|
2359
|
+
raw_parameter: raw_parameter,
|
|
2360
|
+
expect: {
|
|
2361
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2362
|
+
code: getSubstring(status, 128),
|
|
2363
|
+
content_type: "json",
|
|
2364
|
+
is_default: 1,
|
|
2365
|
+
mock: "",
|
|
2366
|
+
schema: jsonSchema,
|
|
2367
|
+
verify_type: "schema",
|
|
2368
|
+
},
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
else if (String(status) == '404') {
|
|
2372
|
+
example.push({
|
|
2373
|
+
example_id: "2",
|
|
2374
|
+
raw: Raw_text,
|
|
2375
|
+
raw_parameter: raw_parameter,
|
|
2376
|
+
expect: {
|
|
2377
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2378
|
+
code: getSubstring(status, 128),
|
|
2379
|
+
content_type: "json",
|
|
2380
|
+
is_default: -1,
|
|
2381
|
+
mock: "",
|
|
2382
|
+
schema: jsonSchema,
|
|
2383
|
+
verify_type: "schema",
|
|
2384
|
+
},
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
else {
|
|
2388
|
+
// 其他示例
|
|
2389
|
+
const newUUID = apipostTools.snowflakeId();
|
|
2390
|
+
example.push({
|
|
2391
|
+
example_id: newUUID,
|
|
2392
|
+
raw: Raw_text,
|
|
2393
|
+
raw_parameter: raw_parameter,
|
|
2394
|
+
expect: {
|
|
2395
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2396
|
+
code: getSubstring(status, 128),
|
|
2397
|
+
content_type: "json",
|
|
2398
|
+
is_default: -1,
|
|
2399
|
+
mock: "",
|
|
2400
|
+
schema: jsonSchema,
|
|
2401
|
+
verify_type: "schema",
|
|
2402
|
+
},
|
|
2403
|
+
});
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
else if (lodash.has(element, "content") &&
|
|
2407
|
+
((_c = Object.keys(element.content)) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
2408
|
+
const content = element.content;
|
|
2409
|
+
const mode = content instanceof Object ? Object.keys(content)[0] : "none";
|
|
2410
|
+
const bodyData = (content === null || content === void 0 ? void 0 : content[mode]) || {};
|
|
2411
|
+
const apipostMode = getApipostMode(mode);
|
|
2412
|
+
// let properties: any = {};
|
|
2413
|
+
if (lodash.has(bodyData, "schema")) {
|
|
2414
|
+
const { schema } = bodyData;
|
|
2415
|
+
if (lodash.has(schema, "properties")) ;
|
|
2416
|
+
if (lodash.has(schema, "items")) ;
|
|
2417
|
+
}
|
|
2418
|
+
if (apipostMode == "json") {
|
|
2419
|
+
let jsonSchema = {};
|
|
2420
|
+
if (Object.prototype.toString.call((_d = bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema) === null || _d === void 0 ? void 0 : _d["$$ref"]) === "[object String]") {
|
|
2421
|
+
jsonSchema = swaggerSchema2apipostSchema(bodyData.schema);
|
|
2422
|
+
}
|
|
2423
|
+
else if (lodash.isPlainObject(bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema)) {
|
|
2424
|
+
jsonSchema = bodyData.schema;
|
|
2425
|
+
}
|
|
2426
|
+
if (lodash.has(bodyData, "example")) {
|
|
2427
|
+
const example = bodyData.example;
|
|
2428
|
+
if (status == 200 || status == 404) {
|
|
2429
|
+
let originRaw;
|
|
2430
|
+
try {
|
|
2431
|
+
if (Object.prototype.toString.call(example) ===
|
|
2432
|
+
"[object Object]") {
|
|
2433
|
+
originRaw = JSON.stringify(Object.assign({}, example));
|
|
2434
|
+
}
|
|
2435
|
+
else {
|
|
2436
|
+
originRaw = String(example);
|
|
2437
|
+
}
|
|
2438
|
+
}
|
|
2439
|
+
catch (error) {
|
|
2440
|
+
originRaw = String(example);
|
|
2441
|
+
}
|
|
2442
|
+
const Raw_text = getBeautifulRaw(originRaw);
|
|
2443
|
+
example.push({
|
|
2444
|
+
example_id: status == 200 ? "1" : "2",
|
|
2445
|
+
raw: Raw_text,
|
|
2446
|
+
raw_parameter: [],
|
|
2447
|
+
expect: {
|
|
2448
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2449
|
+
code: getSubstring(status, 128),
|
|
2450
|
+
content_type: "json",
|
|
2451
|
+
is_default: status == 200 ? 1 : -1,
|
|
2452
|
+
mock: "",
|
|
2453
|
+
schema: jsonSchema,
|
|
2454
|
+
verify_type: "schema",
|
|
2455
|
+
},
|
|
2456
|
+
});
|
|
2457
|
+
}
|
|
2458
|
+
else {
|
|
2459
|
+
// 其他示例
|
|
2460
|
+
const newUUID = apipostTools.snowflakeId();
|
|
2461
|
+
let originRaw;
|
|
2462
|
+
try {
|
|
2463
|
+
if (Object.prototype.toString.call(example) ===
|
|
2464
|
+
"[object Object]") {
|
|
2465
|
+
originRaw = JSON.stringify(Object.assign({}, example));
|
|
2466
|
+
}
|
|
2467
|
+
else {
|
|
2468
|
+
originRaw = example;
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2471
|
+
catch (error) {
|
|
2472
|
+
originRaw = String(example);
|
|
2473
|
+
}
|
|
2474
|
+
const Raw_text = getBeautifulRaw(originRaw);
|
|
2475
|
+
example.push({
|
|
2476
|
+
example_id: newUUID,
|
|
2477
|
+
raw: Raw_text,
|
|
2478
|
+
raw_parameter: [],
|
|
2479
|
+
expect: {
|
|
2480
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2481
|
+
code: getSubstring(status, 128),
|
|
2482
|
+
content_type: "json",
|
|
2483
|
+
is_default: -1,
|
|
2484
|
+
mock: "",
|
|
2485
|
+
schema: jsonSchema,
|
|
2486
|
+
verify_type: "schema",
|
|
2487
|
+
},
|
|
2488
|
+
});
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
else {
|
|
2492
|
+
if (lodash.isPlainObject(bodyData) && lodash.has(bodyData, "schema")) {
|
|
2493
|
+
const raw_parameter = [];
|
|
2494
|
+
const Raw = handleBodyJsonSchema((bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema) || {}, raw_parameter);
|
|
2495
|
+
const originRaw = lodash.isPlainObject(Raw) || Array.isArray(Raw)
|
|
2496
|
+
? JSON.stringify(Raw)
|
|
2497
|
+
: String(Raw);
|
|
2498
|
+
const Raw_text = getBeautifulRaw(originRaw);
|
|
2499
|
+
if (status == 200 || status == 404) {
|
|
2500
|
+
example.push({
|
|
2501
|
+
example_id: status == 200 ? "1" : "2",
|
|
2502
|
+
raw: Raw_text,
|
|
2503
|
+
raw_parameter: raw_parameter,
|
|
2504
|
+
expect: {
|
|
2505
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2506
|
+
code: getSubstring(status, 128),
|
|
2507
|
+
content_type: "json",
|
|
2508
|
+
is_default: status == 200 ? 1 : -1,
|
|
2509
|
+
mock: "",
|
|
2510
|
+
schema: jsonSchema,
|
|
2511
|
+
verify_type: "schema",
|
|
2512
|
+
},
|
|
2513
|
+
});
|
|
2514
|
+
}
|
|
2515
|
+
else {
|
|
2516
|
+
// 其他示例
|
|
2517
|
+
const newUUID = apipostTools.snowflakeId();
|
|
2518
|
+
example.push({
|
|
2519
|
+
example_id: newUUID,
|
|
2520
|
+
raw: Raw_text,
|
|
2521
|
+
raw_parameter: raw_parameter,
|
|
2522
|
+
expect: {
|
|
2523
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2524
|
+
code: getSubstring(status, 128),
|
|
2525
|
+
content_type: "json",
|
|
2526
|
+
is_default: -1,
|
|
2527
|
+
mock: "",
|
|
2528
|
+
schema: jsonSchema,
|
|
2529
|
+
verify_type: "schema",
|
|
2530
|
+
},
|
|
2531
|
+
});
|
|
2532
|
+
}
|
|
2533
|
+
}
|
|
2534
|
+
}
|
|
2535
|
+
}
|
|
2536
|
+
}
|
|
2537
|
+
else {
|
|
2538
|
+
example.push({
|
|
2539
|
+
example_id: getExampleId(status),
|
|
2540
|
+
raw: "",
|
|
2541
|
+
raw_parameter: [],
|
|
2542
|
+
expect: {
|
|
2543
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status || "", 255),
|
|
2544
|
+
code: getSubstring(status, 128),
|
|
2545
|
+
content_type: "json",
|
|
2546
|
+
is_default: -1,
|
|
2547
|
+
mock: "",
|
|
2548
|
+
schema: { type: "object", properties: {} },
|
|
2549
|
+
verify_type: "schema",
|
|
2550
|
+
},
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
});
|
|
2554
|
+
}
|
|
2555
|
+
return {
|
|
2556
|
+
is_check_result: 1,
|
|
2557
|
+
example,
|
|
2558
|
+
};
|
|
2559
|
+
};
|
|
2560
|
+
const completionWs2Config = () => {
|
|
2561
|
+
// if (isPlainObject(config)) {
|
|
2562
|
+
// return {
|
|
2563
|
+
// information_size: config?.information_size || 5,
|
|
2564
|
+
// certificate_verification: config?.certificate_verification || -1,
|
|
2565
|
+
// reconnect_num: config?.reconnect_num || 5,
|
|
2566
|
+
// reconnect_time: config?.reconnect_time || 5000,
|
|
2567
|
+
// shake_hands_timeout: config?.shake_hands_timeout || 0,
|
|
2568
|
+
// };
|
|
2569
|
+
// }
|
|
2570
|
+
return {
|
|
2571
|
+
certificate_verification: -1,
|
|
2572
|
+
information_size: 5,
|
|
2573
|
+
reconnect_num: 5,
|
|
2574
|
+
reconnect_time: 5000,
|
|
2575
|
+
shake_hands_timeout: 0,
|
|
2576
|
+
};
|
|
2577
|
+
};
|
|
2578
|
+
const completionSocketIoConfig = () => {
|
|
2579
|
+
// if (isPlainObject(config)) {
|
|
2580
|
+
// return {
|
|
2581
|
+
// reconnect_num: config?.reconnect_num || 5,
|
|
2582
|
+
// reconnect_time: config?.reconnect_time || 5000,
|
|
2583
|
+
// shake_hands_path: config?.shake_hands_path || '/socket.io',
|
|
2584
|
+
// shake_hands_timeout: config?.shake_hands_timeout || 0,
|
|
2585
|
+
// socket_version: config?.socket_version || 'v4',
|
|
2586
|
+
// certificate_verification: config?.certificate_verification || -1,
|
|
2587
|
+
// };
|
|
2588
|
+
// }
|
|
2589
|
+
return {
|
|
2590
|
+
reconnect_num: 5,
|
|
2591
|
+
reconnect_time: 5000,
|
|
2592
|
+
shake_hands_path: '/socket.io',
|
|
2593
|
+
shake_hands_timeout: 0,
|
|
2594
|
+
socket_version: 'v4',
|
|
2595
|
+
certificate_verification: -1,
|
|
2596
|
+
};
|
|
2597
|
+
};
|
|
2598
|
+
const completionWs2Request = (swaggerApi) => {
|
|
2599
|
+
const parameters = lodash.isArray(swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.parameters) ? swaggerApi.parameters : [];
|
|
2600
|
+
return {
|
|
2601
|
+
header: {
|
|
2602
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'header' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2603
|
+
},
|
|
2604
|
+
query: {
|
|
2605
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'query' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2606
|
+
},
|
|
2607
|
+
cookie: {
|
|
2608
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'cookie' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2609
|
+
},
|
|
2610
|
+
};
|
|
2611
|
+
};
|
|
2612
|
+
const completionWs2Message = (swaggerApi) => {
|
|
2613
|
+
var _a;
|
|
2614
|
+
const content = ((_a = swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.requestBody) === null || _a === void 0 ? void 0 : _a.content) || {};
|
|
2615
|
+
const msg = lodash.values(content);
|
|
2616
|
+
return msg === null || msg === void 0 ? void 0 : msg.map((item) => {
|
|
2617
|
+
const response = (item === null || item === void 0 ? void 0 : item['x-response']) || {};
|
|
2618
|
+
return {
|
|
2619
|
+
name: (item === null || item === void 0 ? void 0 : item['x-summary']) || 'Message',
|
|
2620
|
+
param_id: apipostTools.snowflakeId(),
|
|
2621
|
+
request: {
|
|
2622
|
+
mode: (item === null || item === void 0 ? void 0 : item['x-mode']) || 'text',
|
|
2623
|
+
raw: (item === null || item === void 0 ? void 0 : item.example) || '',
|
|
2624
|
+
raw_parameter: [],
|
|
2625
|
+
raw_schema: (item === null || item === void 0 ? void 0 : item.schema) || {},
|
|
2626
|
+
},
|
|
2627
|
+
response: {
|
|
2628
|
+
mode: (response === null || response === void 0 ? void 0 : response['x-mode']) || 'text',
|
|
2629
|
+
raw: (response === null || response === void 0 ? void 0 : response.example) || '',
|
|
2630
|
+
raw_parameter: [],
|
|
2631
|
+
raw_schema: (response === null || response === void 0 ? void 0 : response.schema) || {},
|
|
2632
|
+
},
|
|
2633
|
+
};
|
|
2634
|
+
});
|
|
2635
|
+
};
|
|
2636
|
+
const completionSocketIoRequest = (swaggerApi) => {
|
|
2637
|
+
var _a;
|
|
2638
|
+
const parameters = lodash.isArray(swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.parameters) ? swaggerApi.parameters : [];
|
|
2639
|
+
return {
|
|
2640
|
+
header: {
|
|
2641
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'header' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2642
|
+
},
|
|
2643
|
+
query: {
|
|
2644
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'query' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2645
|
+
},
|
|
2646
|
+
cookie: {
|
|
2647
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'cookie' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2648
|
+
},
|
|
2649
|
+
event: {
|
|
2650
|
+
parameter: lodash.isArray(parameters)
|
|
2651
|
+
? (_a = parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'event' && (p === null || p === void 0 ? void 0 : p.name))) === null || _a === void 0 ? void 0 : _a.map(({ description = '', schema = {}, is_checked = 1, name = '', example, required = true, }) => ({
|
|
2652
|
+
param_id: apipostTools.snowflakeId(),
|
|
2653
|
+
description,
|
|
2654
|
+
field_type: (schema === null || schema === void 0 ? void 0 : schema.type) || 'string',
|
|
2655
|
+
is_checked,
|
|
2656
|
+
key: name,
|
|
2657
|
+
value: lodash.isEqual(example, '1') ? example : '-1',
|
|
2658
|
+
not_null: required ? 1 : -1,
|
|
2659
|
+
}))
|
|
2660
|
+
: [],
|
|
2661
|
+
},
|
|
2662
|
+
};
|
|
2663
|
+
};
|
|
2664
|
+
const completionGraphqlRequestBody = (swaggerApi) => {
|
|
2665
|
+
var _a, _b;
|
|
2666
|
+
const content = ((_a = swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.requestBody) === null || _a === void 0 ? void 0 : _a.content) || {};
|
|
2667
|
+
const query_schema = ((_b = swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.requestBody) === null || _b === void 0 ? void 0 : _b['x-schema']) || {};
|
|
2668
|
+
return {
|
|
2669
|
+
query_list: lodash.values(content).map(item => {
|
|
2670
|
+
const response = (item === null || item === void 0 ? void 0 : item['x-response']) || {};
|
|
2671
|
+
return {
|
|
2672
|
+
param_id: apipostTools.snowflakeId(),
|
|
2673
|
+
name: item === null || item === void 0 ? void 0 : item['x-summary'],
|
|
2674
|
+
query: item === null || item === void 0 ? void 0 : item['x-query'],
|
|
2675
|
+
variables: item === null || item === void 0 ? void 0 : item['x-variables'],
|
|
2676
|
+
response: {
|
|
2677
|
+
mode: (response === null || response === void 0 ? void 0 : response['x-mode']) || 'json',
|
|
2678
|
+
raw: (response === null || response === void 0 ? void 0 : response.example) || '',
|
|
2679
|
+
raw_parameter: [],
|
|
2680
|
+
raw_schema: (response === null || response === void 0 ? void 0 : response.schema) || {},
|
|
2681
|
+
},
|
|
2682
|
+
};
|
|
2683
|
+
}),
|
|
2684
|
+
query_schema: lodash.isPlainObject(query_schema) ? query_schema : {},
|
|
2685
|
+
};
|
|
2686
|
+
};
|
|
2687
|
+
const completionGraphqlRequest = (swaggerApi) => {
|
|
2688
|
+
const parameters = lodash.isArray(swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.parameters) ? swaggerApi.parameters : [];
|
|
2689
|
+
return {
|
|
2690
|
+
header: {
|
|
2691
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'header' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2692
|
+
},
|
|
2693
|
+
cookie: {
|
|
2694
|
+
parameter: completionParameter(parameters.filter(p => (p === null || p === void 0 ? void 0 : p.in) === 'cookie' && (p === null || p === void 0 ? void 0 : p.name))),
|
|
2695
|
+
},
|
|
2696
|
+
pre_tasks: [],
|
|
2697
|
+
post_tasks: [],
|
|
2698
|
+
body: completionGraphqlRequestBody(swaggerApi),
|
|
2699
|
+
};
|
|
2700
|
+
};
|
|
2701
|
+
const completionSocketMethodBody = (swaggerApi) => {
|
|
2702
|
+
var _a;
|
|
2703
|
+
const content = ((_a = swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.requestBody) === null || _a === void 0 ? void 0 : _a.content) || {};
|
|
2704
|
+
const mode = lodash.isPlainObject(content) && !lodash.isEmpty(content) ? Object.keys(content)[0] : "none";
|
|
2705
|
+
const bodyData = (content === null || content === void 0 ? void 0 : content[mode]) || {};
|
|
2706
|
+
const apipostMode = (MODE_TYPE2 === null || MODE_TYPE2 === void 0 ? void 0 : MODE_TYPE2[mode]) || 'xml';
|
|
2707
|
+
return {
|
|
2708
|
+
mode: apipostMode,
|
|
2709
|
+
parameter: [],
|
|
2710
|
+
raw: (bodyData === null || bodyData === void 0 ? void 0 : bodyData.example) || '',
|
|
2711
|
+
raw_parameter: [],
|
|
2712
|
+
raw_schema: (bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema) || {},
|
|
2713
|
+
};
|
|
2714
|
+
};
|
|
2715
|
+
const completionSocketMethodRequest = (swaggerApi) => {
|
|
2716
|
+
return {
|
|
2717
|
+
body: completionSocketMethodBody(swaggerApi),
|
|
2718
|
+
post_tasks: [],
|
|
2719
|
+
configs: {
|
|
2720
|
+
charset: 'utf8',
|
|
2721
|
+
func: {
|
|
2722
|
+
request: [],
|
|
2723
|
+
response: [],
|
|
2724
|
+
},
|
|
2725
|
+
},
|
|
2726
|
+
};
|
|
2727
|
+
};
|
|
2190
2728
|
|
|
2191
2729
|
class SwaggerToApipost {
|
|
2192
2730
|
constructor() {
|
|
@@ -2370,14 +2908,18 @@ class SwaggerToApipost {
|
|
|
2370
2908
|
}
|
|
2371
2909
|
}
|
|
2372
2910
|
createNewFolder(name, tags) {
|
|
2373
|
-
|
|
2374
|
-
const description = (
|
|
2911
|
+
const tagData = tags === null || tags === void 0 ? void 0 : tags.find((tag) => tag.name === name);
|
|
2912
|
+
const description = (tagData === null || tagData === void 0 ? void 0 : tagData.description) || "";
|
|
2375
2913
|
const newFolder = {
|
|
2376
2914
|
name: name,
|
|
2377
2915
|
target_type: "folder",
|
|
2378
2916
|
description: description,
|
|
2379
2917
|
children: [],
|
|
2380
2918
|
};
|
|
2919
|
+
if ((tagData === null || tagData === void 0 ? void 0 : tagData['x-type']) === 'socket') {
|
|
2920
|
+
newFolder.url = (tagData === null || tagData === void 0 ? void 0 : tagData['x-url']) || "";
|
|
2921
|
+
newFolder.method = 'TCP';
|
|
2922
|
+
}
|
|
2381
2923
|
this.folderNames[name] = true;
|
|
2382
2924
|
return newFolder;
|
|
2383
2925
|
}
|
|
@@ -2408,28 +2950,29 @@ class SwaggerToApipost {
|
|
|
2408
2950
|
}
|
|
2409
2951
|
handlePathV3(path, pathItem, tags) {
|
|
2410
2952
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2411
|
-
var _a, _b, _c, _d, _e, _f
|
|
2953
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2412
2954
|
let url = path;
|
|
2413
2955
|
for (const method in pathItem) {
|
|
2414
2956
|
const swaggerApi = pathItem[method];
|
|
2415
|
-
if (Object.prototype.toString.call(swaggerApi) !== "[object Object]")
|
|
2416
|
-
|
|
2417
|
-
|
|
2957
|
+
if (Object.prototype.toString.call(swaggerApi) !== "[object Object]") {
|
|
2958
|
+
continue;
|
|
2959
|
+
}
|
|
2960
|
+
let protocol = 'http';
|
|
2418
2961
|
if (lodash.has(swaggerApi, "x-protocol") && swaggerApi['x-protocol'] !== 'http') {
|
|
2419
|
-
|
|
2962
|
+
protocol = swaggerApi['x-protocol'];
|
|
2420
2963
|
}
|
|
2421
2964
|
if (lodash.has(swaggerApi, "tags") && swaggerApi.tags.length > 0) {
|
|
2422
2965
|
this.handleTags(lodash.uniq(swaggerApi.tags), tags);
|
|
2423
2966
|
}
|
|
2424
|
-
|
|
2967
|
+
let baseApiInfo = {
|
|
2425
2968
|
name: (swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.summary) ||
|
|
2426
2969
|
(swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.__originalOperationId) ||
|
|
2427
2970
|
(swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.operationId) ||
|
|
2428
2971
|
"New HTTP",
|
|
2429
2972
|
target_type: "api",
|
|
2430
2973
|
tags: [],
|
|
2974
|
+
target_type: protocol,
|
|
2431
2975
|
url: url || "",
|
|
2432
|
-
method: completionMethod(method),
|
|
2433
2976
|
description: (swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.description) || "",
|
|
2434
2977
|
request: {},
|
|
2435
2978
|
response: {
|
|
@@ -2439,395 +2982,39 @@ class SwaggerToApipost {
|
|
|
2439
2982
|
// '1': 开发中 '4': 已废弃
|
|
2440
2983
|
mark_id: (swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.deprecated) ? "4" : "1",
|
|
2441
2984
|
};
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
if (lodash.has(parameter, "in")) {
|
|
2447
|
-
if (parameter.in == "query") {
|
|
2448
|
-
if (!lodash.has(request, "query")) {
|
|
2449
|
-
request["query"] = {
|
|
2450
|
-
parameter: [],
|
|
2451
|
-
};
|
|
2452
|
-
}
|
|
2453
|
-
(parameter === null || parameter === void 0 ? void 0 : parameter.name) &&
|
|
2454
|
-
request.query.parameter.push({
|
|
2455
|
-
is_checked: 1, // 是否选择
|
|
2456
|
-
key: (parameter === null || parameter === void 0 ? void 0 : parameter.name) || "", //参数名
|
|
2457
|
-
value: transExample(parameter === null || parameter === void 0 ? void 0 : parameter.example) ||
|
|
2458
|
-
transExample((_a = parameter === null || parameter === void 0 ? void 0 : parameter.schema) === null || _a === void 0 ? void 0 : _a.example) ||
|
|
2459
|
-
transExample(parameter === null || parameter === void 0 ? void 0 : parameter.default) ||
|
|
2460
|
-
"", //参数值
|
|
2461
|
-
not_null: (parameter === null || parameter === void 0 ? void 0 : parameter.required) ? 1 : -1, // 是否为空
|
|
2462
|
-
description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
|
|
2463
|
-
field_type: getFidldType((_b = parameter === null || parameter === void 0 ? void 0 : parameter.schema) === null || _b === void 0 ? void 0 : _b.type), // 类型
|
|
2464
|
-
param_id: apipostTools.snowflakeId(),
|
|
2465
|
-
schema: (parameter === null || parameter === void 0 ? void 0 : parameter.schema) || {}
|
|
2466
|
-
});
|
|
2467
|
-
}
|
|
2468
|
-
else if (parameter.in == "header") {
|
|
2469
|
-
if (!lodash.has(request, "header")) {
|
|
2470
|
-
request["header"] = {
|
|
2471
|
-
parameter: [],
|
|
2472
|
-
};
|
|
2473
|
-
}
|
|
2474
|
-
(parameter === null || parameter === void 0 ? void 0 : parameter.name) &&
|
|
2475
|
-
request.header.parameter.push({
|
|
2476
|
-
is_checked: 1, // 是否选择
|
|
2477
|
-
key: (parameter === null || parameter === void 0 ? void 0 : parameter.name) || "", //参数名
|
|
2478
|
-
value: transExample(parameter === null || parameter === void 0 ? void 0 : parameter.example) ||
|
|
2479
|
-
transExample((_c = parameter === null || parameter === void 0 ? void 0 : parameter.schema) === null || _c === void 0 ? void 0 : _c.example) ||
|
|
2480
|
-
transExample(parameter === null || parameter === void 0 ? void 0 : parameter.default) ||
|
|
2481
|
-
"", //参数值
|
|
2482
|
-
not_null: parameter.required ? 1 : -1, // 是否为空
|
|
2483
|
-
description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
|
|
2484
|
-
field_type: getFidldType((_d = parameter === null || parameter === void 0 ? void 0 : parameter.schema) === null || _d === void 0 ? void 0 : _d.type), // 类型
|
|
2485
|
-
param_id: apipostTools.snowflakeId(),
|
|
2486
|
-
schema: (parameter === null || parameter === void 0 ? void 0 : parameter.schema) || {}
|
|
2487
|
-
});
|
|
2488
|
-
}
|
|
2489
|
-
else if (parameter.in == "path") {
|
|
2490
|
-
if (!lodash.has(request, "restful")) {
|
|
2491
|
-
request["restful"] = {
|
|
2492
|
-
parameter: [],
|
|
2493
|
-
};
|
|
2494
|
-
}
|
|
2495
|
-
(parameter === null || parameter === void 0 ? void 0 : parameter.name) &&
|
|
2496
|
-
request.restful.parameter.push({
|
|
2497
|
-
is_checked: 1, // 是否选择
|
|
2498
|
-
key: (parameter === null || parameter === void 0 ? void 0 : parameter.name) || "", //参数名
|
|
2499
|
-
value: transExample(parameter === null || parameter === void 0 ? void 0 : parameter.example) ||
|
|
2500
|
-
transExample((_e = parameter === null || parameter === void 0 ? void 0 : parameter.schema) === null || _e === void 0 ? void 0 : _e.example) ||
|
|
2501
|
-
transExample(parameter === null || parameter === void 0 ? void 0 : parameter.default) ||
|
|
2502
|
-
"", //参数值
|
|
2503
|
-
not_null: parameter.required ? 1 : -1, // 是否为空
|
|
2504
|
-
description: anyToString(parameter === null || parameter === void 0 ? void 0 : parameter.description) || "", // 参数描述
|
|
2505
|
-
field_type: getFidldType((_f = parameter === null || parameter === void 0 ? void 0 : parameter.schema) === null || _f === void 0 ? void 0 : _f.type), // 类型
|
|
2506
|
-
param_id: apipostTools.snowflakeId(),
|
|
2507
|
-
schema: (parameter === null || parameter === void 0 ? void 0 : parameter.schema) || {}
|
|
2508
|
-
});
|
|
2509
|
-
}
|
|
2510
|
-
}
|
|
2511
|
-
}
|
|
2512
|
-
request["restful"] = {
|
|
2513
|
-
parameter: genRestfulByUrl(url, ((_g = request === null || request === void 0 ? void 0 : request.restful) === null || _g === void 0 ? void 0 : _g.parameter) || []),
|
|
2514
|
-
};
|
|
2985
|
+
if (protocol === 'http' || protocol === 'sse') {
|
|
2986
|
+
baseApiInfo = Object.assign(Object.assign({}, baseApiInfo), { target_type: protocol === 'http' ? 'api' : protocol, method: completionMethod(method), protocol: 'http/1.1', request: Object.assign({}, completionRequestParam(swaggerApi)), response: Object.assign({}, completionResponse((swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.response) || {})) });
|
|
2987
|
+
// 根据query参数 重新生成url
|
|
2988
|
+
baseApiInfo.url = genUrlByQuery(baseApiInfo.url, ((_b = (_a = baseApiInfo === null || baseApiInfo === void 0 ? void 0 : baseApiInfo.request) === null || _a === void 0 ? void 0 : _a.restful) === null || _b === void 0 ? void 0 : _b.parameter) || []);
|
|
2515
2989
|
}
|
|
2516
|
-
if (
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
const bodyData = content[mode];
|
|
2521
|
-
const apipostMode = getApipostMode(mode);
|
|
2522
|
-
let properties = {};
|
|
2523
|
-
if (lodash.has(bodyData, "schema")) {
|
|
2524
|
-
const { schema } = bodyData;
|
|
2525
|
-
if ((schema === null || schema === void 0 ? void 0 : schema.type) === "array") {
|
|
2526
|
-
properties = (_h = schema === null || schema === void 0 ? void 0 : schema.items) === null || _h === void 0 ? void 0 : _h.properties;
|
|
2527
|
-
}
|
|
2528
|
-
else {
|
|
2529
|
-
properties = schema === null || schema === void 0 ? void 0 : schema.properties;
|
|
2530
|
-
}
|
|
2531
|
-
}
|
|
2532
|
-
request.body = {
|
|
2533
|
-
mode: apipostMode,
|
|
2534
|
-
parameter: [],
|
|
2535
|
-
raw: "",
|
|
2536
|
-
raw_parameter: [],
|
|
2537
|
-
};
|
|
2538
|
-
if (apipostMode == "urlencoded" || apipostMode == "form-data") {
|
|
2539
|
-
for (const key in properties) {
|
|
2540
|
-
const item = properties[key];
|
|
2541
|
-
key &&
|
|
2542
|
-
request.body.parameter.push({
|
|
2543
|
-
is_checked: 1,
|
|
2544
|
-
key: key || "",
|
|
2545
|
-
value: transExample(item === null || item === void 0 ? void 0 : item.example) || "",
|
|
2546
|
-
not_null: (item === null || item === void 0 ? void 0 : item.required) ? 1 : -1,
|
|
2547
|
-
description: anyToString(item === null || item === void 0 ? void 0 : item.description) || "",
|
|
2548
|
-
field_type: lodash.has(item, "type")
|
|
2549
|
-
? item.type.charAt(0).toUpperCase() + item.type.slice(1)
|
|
2550
|
-
: "String",
|
|
2551
|
-
param_id: apipostTools.snowflakeId(),
|
|
2552
|
-
schema: (item === null || item === void 0 ? void 0 : item.schema) || {}
|
|
2553
|
-
});
|
|
2554
|
-
}
|
|
2555
|
-
}
|
|
2556
|
-
else if (apipostMode == "json") {
|
|
2557
|
-
if (lodash.has(bodyData, "example")) {
|
|
2558
|
-
let example = bodyData.example;
|
|
2559
|
-
if (typeof example == "object") {
|
|
2560
|
-
example = JSON.stringify(example);
|
|
2561
|
-
}
|
|
2562
|
-
request.body.raw = example;
|
|
2563
|
-
}
|
|
2564
|
-
if (lodash.has(bodyData, "schema")) {
|
|
2565
|
-
request.body.raw_schema = swaggerSchema2apipostSchema(bodyData.schema);
|
|
2566
|
-
const raw_parameter = [];
|
|
2567
|
-
const Raw = handleBodyJsonSchema(bodyData.schema, raw_parameter);
|
|
2568
|
-
const Raw_text = lodash.isPlainObject(Raw) || Array.isArray(Raw)
|
|
2569
|
-
? JSON.stringify(Raw)
|
|
2570
|
-
: Raw;
|
|
2571
|
-
request.body.raw = request.body.raw ? request.body.raw : Raw_text;
|
|
2572
|
-
request.body.raw_parameter = raw_parameter;
|
|
2573
|
-
if (lodash.isEmpty(request.body.raw)) {
|
|
2574
|
-
try {
|
|
2575
|
-
const myMockSchema = new MockSchema__default["default"]({
|
|
2576
|
-
app: "echoapi",
|
|
2577
|
-
});
|
|
2578
|
-
const schemaJson = yield myMockSchema.mock(bodyData.schema);
|
|
2579
|
-
request.body.raw =
|
|
2580
|
-
lodash.isPlainObject(schemaJson) || Array.isArray(Raw)
|
|
2581
|
-
? JSON.stringify(schemaJson)
|
|
2582
|
-
: schemaJson;
|
|
2583
|
-
}
|
|
2584
|
-
catch (error) { }
|
|
2585
|
-
}
|
|
2586
|
-
if (typeof request.body.raw == "object") {
|
|
2587
|
-
request.body.raw = `${request.body.raw}`;
|
|
2588
|
-
}
|
|
2589
|
-
}
|
|
2590
|
-
}
|
|
2591
|
-
if (!lodash.isString(request.body.raw)) {
|
|
2592
|
-
request.body.raw = JSON.stringify(request.body.raw);
|
|
2593
|
-
}
|
|
2594
|
-
request.body.raw = this.getBeautifulRaw(request.body.raw);
|
|
2990
|
+
if (protocol === 'websocket2') {
|
|
2991
|
+
baseApiInfo = Object.assign(Object.assign({}, baseApiInfo), { method: '', url, is_socket: 1, config: completionWs2Config(), request: completionWs2Request(swaggerApi), message: completionWs2Message(swaggerApi) });
|
|
2992
|
+
// 根据query参数 重新生成url
|
|
2993
|
+
baseApiInfo.url = genUrlByQuery(baseApiInfo.url, ((_d = (_c = baseApiInfo === null || baseApiInfo === void 0 ? void 0 : baseApiInfo.request) === null || _c === void 0 ? void 0 : _c.restful) === null || _d === void 0 ? void 0 : _d.parameter) || []);
|
|
2595
2994
|
}
|
|
2596
|
-
if (
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
? JSON.stringify(Raw)
|
|
2610
|
-
: String(Raw);
|
|
2611
|
-
const Raw_text = this.getBeautifulRaw(originRaw);
|
|
2612
|
-
let jsonSchema = {};
|
|
2613
|
-
if (Object.prototype.toString.call((_b = element === null || element === void 0 ? void 0 : element.schema) === null || _b === void 0 ? void 0 : _b["$$ref"]) ===
|
|
2614
|
-
"[object String]") {
|
|
2615
|
-
jsonSchema = swaggerSchema2apipostSchema(element.schema);
|
|
2616
|
-
}
|
|
2617
|
-
else {
|
|
2618
|
-
jsonSchema = element.schema;
|
|
2619
|
-
}
|
|
2620
|
-
// 成功响应示例
|
|
2621
|
-
if (String(status) == '200') {
|
|
2622
|
-
response.example.push({
|
|
2623
|
-
example_id: "1",
|
|
2624
|
-
raw: Raw_text,
|
|
2625
|
-
raw_parameter: raw_parameter,
|
|
2626
|
-
expect: {
|
|
2627
|
-
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2628
|
-
code: getSubstring(status, 128),
|
|
2629
|
-
content_type: "json",
|
|
2630
|
-
is_default: 1,
|
|
2631
|
-
mock: "",
|
|
2632
|
-
schema: jsonSchema,
|
|
2633
|
-
verify_type: "schema",
|
|
2634
|
-
},
|
|
2635
|
-
});
|
|
2636
|
-
}
|
|
2637
|
-
else if (String(status) == '404') {
|
|
2638
|
-
response.example.push({
|
|
2639
|
-
example_id: "2",
|
|
2640
|
-
raw: Raw_text,
|
|
2641
|
-
raw_parameter: raw_parameter,
|
|
2642
|
-
expect: {
|
|
2643
|
-
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2644
|
-
code: getSubstring(status, 128),
|
|
2645
|
-
content_type: "json",
|
|
2646
|
-
is_default: -1,
|
|
2647
|
-
mock: "",
|
|
2648
|
-
schema: jsonSchema,
|
|
2649
|
-
verify_type: "schema",
|
|
2650
|
-
},
|
|
2651
|
-
});
|
|
2652
|
-
}
|
|
2653
|
-
else {
|
|
2654
|
-
// 其他示例
|
|
2655
|
-
const newUUID = apipostTools.snowflakeId();
|
|
2656
|
-
response.example.push({
|
|
2657
|
-
example_id: newUUID,
|
|
2658
|
-
raw: Raw_text,
|
|
2659
|
-
raw_parameter: raw_parameter,
|
|
2660
|
-
expect: {
|
|
2661
|
-
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2662
|
-
code: getSubstring(status, 128),
|
|
2663
|
-
content_type: "json",
|
|
2664
|
-
is_default: -1,
|
|
2665
|
-
mock: "",
|
|
2666
|
-
schema: jsonSchema,
|
|
2667
|
-
verify_type: "schema",
|
|
2668
|
-
},
|
|
2669
|
-
});
|
|
2670
|
-
}
|
|
2671
|
-
}
|
|
2672
|
-
else if (lodash.has(element, "content") &&
|
|
2673
|
-
((_c = Object.keys(element.content)) === null || _c === void 0 ? void 0 : _c.length) > 0) {
|
|
2674
|
-
const content = element.content;
|
|
2675
|
-
const mode = content instanceof Object ? Object.keys(content)[0] : "none";
|
|
2676
|
-
const bodyData = content[mode];
|
|
2677
|
-
const apipostMode = getApipostMode(mode);
|
|
2678
|
-
// let properties: any = {};
|
|
2679
|
-
if (lodash.has(bodyData, "schema")) {
|
|
2680
|
-
const { schema } = bodyData;
|
|
2681
|
-
if (lodash.has(schema, "properties")) ;
|
|
2682
|
-
if (lodash.has(schema, "items")) ;
|
|
2683
|
-
}
|
|
2684
|
-
if (apipostMode == "json") {
|
|
2685
|
-
let jsonSchema = {};
|
|
2686
|
-
if (Object.prototype.toString.call((_d = bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema) === null || _d === void 0 ? void 0 : _d["$$ref"]) === "[object String]") {
|
|
2687
|
-
jsonSchema = swaggerSchema2apipostSchema(bodyData.schema);
|
|
2688
|
-
}
|
|
2689
|
-
else if (lodash.isPlainObject(bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema)) {
|
|
2690
|
-
jsonSchema = bodyData.schema;
|
|
2691
|
-
}
|
|
2692
|
-
if (lodash.has(bodyData, "example")) {
|
|
2693
|
-
const example = bodyData.example;
|
|
2694
|
-
if (status == 200 || status == 404) {
|
|
2695
|
-
let originRaw;
|
|
2696
|
-
try {
|
|
2697
|
-
if (Object.prototype.toString.call(example) ===
|
|
2698
|
-
"[object Object]") {
|
|
2699
|
-
originRaw = JSON.stringify(Object.assign({}, example));
|
|
2700
|
-
}
|
|
2701
|
-
else {
|
|
2702
|
-
originRaw = String(example);
|
|
2703
|
-
}
|
|
2704
|
-
}
|
|
2705
|
-
catch (error) {
|
|
2706
|
-
originRaw = String(example);
|
|
2707
|
-
}
|
|
2708
|
-
const Raw_text = this.getBeautifulRaw(originRaw);
|
|
2709
|
-
response.example.push({
|
|
2710
|
-
example_id: status == 200 ? "1" : "2",
|
|
2711
|
-
raw: Raw_text,
|
|
2712
|
-
raw_parameter: [],
|
|
2713
|
-
expect: {
|
|
2714
|
-
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2715
|
-
code: getSubstring(status, 128),
|
|
2716
|
-
content_type: "json",
|
|
2717
|
-
is_default: status == 200 ? 1 : -1,
|
|
2718
|
-
mock: "",
|
|
2719
|
-
schema: jsonSchema,
|
|
2720
|
-
verify_type: "schema",
|
|
2721
|
-
},
|
|
2722
|
-
});
|
|
2723
|
-
}
|
|
2724
|
-
else {
|
|
2725
|
-
// 其他示例
|
|
2726
|
-
const newUUID = apipostTools.snowflakeId();
|
|
2727
|
-
let originRaw;
|
|
2728
|
-
try {
|
|
2729
|
-
if (Object.prototype.toString.call(example) ===
|
|
2730
|
-
"[object Object]") {
|
|
2731
|
-
originRaw = JSON.stringify(Object.assign({}, example));
|
|
2732
|
-
}
|
|
2733
|
-
else {
|
|
2734
|
-
originRaw = example;
|
|
2735
|
-
}
|
|
2736
|
-
}
|
|
2737
|
-
catch (error) {
|
|
2738
|
-
originRaw = String(example);
|
|
2739
|
-
}
|
|
2740
|
-
const Raw_text = this.getBeautifulRaw(originRaw);
|
|
2741
|
-
response.example.push({
|
|
2742
|
-
example_id: newUUID,
|
|
2743
|
-
raw: Raw_text,
|
|
2744
|
-
raw_parameter: [],
|
|
2745
|
-
expect: {
|
|
2746
|
-
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2747
|
-
code: getSubstring(status, 128),
|
|
2748
|
-
content_type: "json",
|
|
2749
|
-
is_default: -1,
|
|
2750
|
-
mock: "",
|
|
2751
|
-
schema: jsonSchema,
|
|
2752
|
-
verify_type: "schema",
|
|
2753
|
-
},
|
|
2754
|
-
});
|
|
2755
|
-
}
|
|
2756
|
-
}
|
|
2757
|
-
else {
|
|
2758
|
-
if (lodash.has(bodyData, "schema")) {
|
|
2759
|
-
const raw_parameter = [];
|
|
2760
|
-
const Raw = handleBodyJsonSchema(bodyData.schema, raw_parameter);
|
|
2761
|
-
const originRaw = lodash.isPlainObject(Raw) || Array.isArray(Raw)
|
|
2762
|
-
? JSON.stringify(Raw)
|
|
2763
|
-
: String(Raw);
|
|
2764
|
-
const Raw_text = this.getBeautifulRaw(originRaw);
|
|
2765
|
-
if (status == 200 || status == 404) {
|
|
2766
|
-
response.example.push({
|
|
2767
|
-
example_id: status == 200 ? "1" : "2",
|
|
2768
|
-
raw: Raw_text,
|
|
2769
|
-
raw_parameter: raw_parameter,
|
|
2770
|
-
expect: {
|
|
2771
|
-
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2772
|
-
code: getSubstring(status, 128),
|
|
2773
|
-
content_type: "json",
|
|
2774
|
-
is_default: status == 200 ? 1 : -1,
|
|
2775
|
-
mock: "",
|
|
2776
|
-
schema: jsonSchema,
|
|
2777
|
-
verify_type: "schema",
|
|
2778
|
-
},
|
|
2779
|
-
});
|
|
2780
|
-
}
|
|
2781
|
-
else {
|
|
2782
|
-
// 其他示例
|
|
2783
|
-
const newUUID = apipostTools.snowflakeId();
|
|
2784
|
-
response.example.push({
|
|
2785
|
-
example_id: newUUID,
|
|
2786
|
-
raw: Raw_text,
|
|
2787
|
-
raw_parameter: raw_parameter,
|
|
2788
|
-
expect: {
|
|
2789
|
-
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2790
|
-
code: getSubstring(status, 128),
|
|
2791
|
-
content_type: "json",
|
|
2792
|
-
is_default: -1,
|
|
2793
|
-
mock: "",
|
|
2794
|
-
schema: jsonSchema,
|
|
2795
|
-
verify_type: "schema",
|
|
2796
|
-
},
|
|
2797
|
-
});
|
|
2798
|
-
}
|
|
2799
|
-
}
|
|
2800
|
-
}
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
else {
|
|
2804
|
-
response.example.push({
|
|
2805
|
-
example_id: getExampleId(status),
|
|
2806
|
-
raw: "",
|
|
2807
|
-
raw_parameter: [],
|
|
2808
|
-
expect: {
|
|
2809
|
-
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status || "", 255),
|
|
2810
|
-
code: getSubstring(status, 128),
|
|
2811
|
-
content_type: "json",
|
|
2812
|
-
is_default: -1,
|
|
2813
|
-
mock: "",
|
|
2814
|
-
schema: { type: "object", properties: {} },
|
|
2815
|
-
verify_type: "schema",
|
|
2816
|
-
},
|
|
2817
|
-
});
|
|
2818
|
-
}
|
|
2819
|
-
});
|
|
2820
|
-
}
|
|
2995
|
+
if (protocol === 'socketio') {
|
|
2996
|
+
baseApiInfo = Object.assign(Object.assign({}, baseApiInfo), { method: '', url, request: completionSocketIoRequest(swaggerApi), message: completionWs2Message(swaggerApi), config: completionSocketIoConfig() });
|
|
2997
|
+
// 根据query参数 重新生成url
|
|
2998
|
+
baseApiInfo.url = genUrlByQuery(baseApiInfo.url, ((_f = (_e = baseApiInfo === null || baseApiInfo === void 0 ? void 0 : baseApiInfo.request) === null || _e === void 0 ? void 0 : _e.restful) === null || _f === void 0 ? void 0 : _f.parameter) || []);
|
|
2999
|
+
}
|
|
3000
|
+
if (protocol === 'graphql') {
|
|
3001
|
+
baseApiInfo = Object.assign(Object.assign({}, baseApiInfo), { url, request: completionGraphqlRequest(swaggerApi), response: completionResponse((swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.response) || {}) });
|
|
3002
|
+
}
|
|
3003
|
+
if (protocol === 'socket_method') {
|
|
3004
|
+
baseApiInfo = Object.assign(Object.assign({}, baseApiInfo), { method: 'TCP', url, request: completionSocketMethodRequest(swaggerApi), response: Object.assign({}, completionResponse((swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.response) || {})) });
|
|
3005
|
+
}
|
|
3006
|
+
if (protocol === 'doc') {
|
|
3007
|
+
baseApiInfo = Object.assign({}, baseApiInfo);
|
|
2821
3008
|
}
|
|
2822
3009
|
if (lodash.has(swaggerApi, "tags") && swaggerApi.tags.length > 0) {
|
|
2823
3010
|
for (const folder of lodash.uniq(swaggerApi.tags)) {
|
|
2824
3011
|
if (lodash.has(this.folders, folder)) {
|
|
2825
|
-
this.folders[folder].children.push(
|
|
3012
|
+
this.folders[folder].children.push(baseApiInfo);
|
|
2826
3013
|
}
|
|
2827
3014
|
}
|
|
2828
3015
|
}
|
|
2829
3016
|
else {
|
|
2830
|
-
this.apis.push(
|
|
3017
|
+
this.apis.push(baseApiInfo);
|
|
2831
3018
|
}
|
|
2832
3019
|
}
|
|
2833
3020
|
});
|
|
@@ -2874,7 +3061,7 @@ class SwaggerToApipost {
|
|
|
2874
3061
|
for (const method in pathItem) {
|
|
2875
3062
|
const swaggerApi = pathItem[method];
|
|
2876
3063
|
if (Object.prototype.toString.call(swaggerApi) !== "[object Object]")
|
|
2877
|
-
|
|
3064
|
+
continue;
|
|
2878
3065
|
if (lodash.has(swaggerApi, "tags") && swaggerApi.tags.length > 0) {
|
|
2879
3066
|
this.handleTags(lodash.uniq(swaggerApi.tags), tags);
|
|
2880
3067
|
}
|
|
@@ -3510,7 +3697,7 @@ class ApidocToApipost {
|
|
|
3510
3697
|
pre.push({
|
|
3511
3698
|
example_id: apipostTools.snowflakeId(),
|
|
3512
3699
|
raw_parameter: [],
|
|
3513
|
-
raw: getBeautifulRaw(raw || ""),
|
|
3700
|
+
raw: getBeautifulRaw$1(raw || ""),
|
|
3514
3701
|
expect: {
|
|
3515
3702
|
code: "200",
|
|
3516
3703
|
content_type: "json",
|
|
@@ -3534,7 +3721,7 @@ class ApidocToApipost {
|
|
|
3534
3721
|
pre.push({
|
|
3535
3722
|
example_id: apipostTools.snowflakeId(),
|
|
3536
3723
|
raw_parameter: [],
|
|
3537
|
-
raw: getBeautifulRaw(raw || ""),
|
|
3724
|
+
raw: getBeautifulRaw$1(raw || ""),
|
|
3538
3725
|
expect: {
|
|
3539
3726
|
code: "400",
|
|
3540
3727
|
content_type: "json",
|
|
@@ -4347,19 +4534,19 @@ class ApifoxToApipost {
|
|
|
4347
4534
|
}
|
|
4348
4535
|
else if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody[type]) === "application/x-msgpack") {
|
|
4349
4536
|
body["mode"] = "msgpack";
|
|
4350
|
-
body["raw"] = getBeautifulRaw((requestBody === null || requestBody === void 0 ? void 0 : requestBody.example) || "");
|
|
4537
|
+
body["raw"] = getBeautifulRaw$1((requestBody === null || requestBody === void 0 ? void 0 : requestBody.example) || "");
|
|
4351
4538
|
body["raw_schema"] = this.recursionSchema((requestBody === null || requestBody === void 0 ? void 0 : requestBody.jsonSchema) || { type: "object", properties: {} }, this.modelMap);
|
|
4352
4539
|
}
|
|
4353
4540
|
else if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody[type]) === "application/json" ||
|
|
4354
4541
|
(requestBody === null || requestBody === void 0 ? void 0 : requestBody[type]) === "json") {
|
|
4355
4542
|
body["mode"] = "json";
|
|
4356
|
-
body["raw"] = getBeautifulRaw((requestBody === null || requestBody === void 0 ? void 0 : requestBody.example) || "");
|
|
4543
|
+
body["raw"] = getBeautifulRaw$1((requestBody === null || requestBody === void 0 ? void 0 : requestBody.example) || "");
|
|
4357
4544
|
body["raw_schema"] = this.recursionSchema((requestBody === null || requestBody === void 0 ? void 0 : requestBody.jsonSchema) || { type: "object", properties: {} }, this.modelMap);
|
|
4358
4545
|
}
|
|
4359
4546
|
else if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody[type]) === "application/xml" ||
|
|
4360
4547
|
(requestBody === null || requestBody === void 0 ? void 0 : requestBody[type]) === "xml") {
|
|
4361
4548
|
body["mode"] = "xml";
|
|
4362
|
-
body["raw"] = getBeautifulRaw((requestBody === null || requestBody === void 0 ? void 0 : requestBody.example) || "");
|
|
4549
|
+
body["raw"] = getBeautifulRaw$1((requestBody === null || requestBody === void 0 ? void 0 : requestBody.example) || "");
|
|
4363
4550
|
body["raw_schema"] = this.recursionSchema((requestBody === null || requestBody === void 0 ? void 0 : requestBody.jsonSchema) || { type: "object", properties: {} }, this.modelMap);
|
|
4364
4551
|
}
|
|
4365
4552
|
else if ((requestBody === null || requestBody === void 0 ? void 0 : requestBody[type]) === "text/plain") {
|
|
@@ -4450,7 +4637,7 @@ class ApifoxToApipost {
|
|
|
4450
4637
|
const raw = responseExamples === null || responseExamples === void 0 ? void 0 : responseExamples.find((exampleItem) => (exampleItem === null || exampleItem === void 0 ? void 0 : exampleItem.responseId) == (item === null || item === void 0 ? void 0 : item.id));
|
|
4451
4638
|
return {
|
|
4452
4639
|
example_id: apipostTools.snowflakeId(),
|
|
4453
|
-
raw: raw ? getBeautifulRaw((raw === null || raw === void 0 ? void 0 : raw.data) || "") : "",
|
|
4640
|
+
raw: raw ? getBeautifulRaw$1((raw === null || raw === void 0 ? void 0 : raw.data) || "") : "",
|
|
4454
4641
|
raw_parameter: [],
|
|
4455
4642
|
expect: {
|
|
4456
4643
|
name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "",
|
|
@@ -5701,7 +5888,7 @@ class HarToApipost {
|
|
|
5701
5888
|
(lodash.isString((_b = request === null || request === void 0 ? void 0 : request.postData) === null || _b === void 0 ? void 0 : _b.mimeType) &&
|
|
5702
5889
|
((_d = (_c = request === null || request === void 0 ? void 0 : request.postData) === null || _c === void 0 ? void 0 : _c.mimeType) === null || _d === void 0 ? void 0 : _d.includes("application/json")))) {
|
|
5703
5890
|
body["mode"] = "json";
|
|
5704
|
-
body["raw"] = getBeautifulRaw(((_e = request === null || request === void 0 ? void 0 : request.postData) === null || _e === void 0 ? void 0 : _e.text) || "");
|
|
5891
|
+
body["raw"] = getBeautifulRaw$1(((_e = request === null || request === void 0 ? void 0 : request.postData) === null || _e === void 0 ? void 0 : _e.text) || "");
|
|
5705
5892
|
}
|
|
5706
5893
|
else if (((_f = request === null || request === void 0 ? void 0 : request.postData) === null || _f === void 0 ? void 0 : _f.mimeType) === "multipart/form-data" ||
|
|
5707
5894
|
(lodash.isString((_g = request === null || request === void 0 ? void 0 : request.postData) === null || _g === void 0 ? void 0 : _g.mimeType) &&
|
|
@@ -5908,7 +6095,7 @@ class InsomniaToApipost {
|
|
|
5908
6095
|
const { body } = item || {};
|
|
5909
6096
|
const bodyParams = {};
|
|
5910
6097
|
const parameter = this.completionParameter((body === null || body === void 0 ? void 0 : body.params) || []);
|
|
5911
|
-
const text = getBeautifulRaw((body === null || body === void 0 ? void 0 : body.text) || "");
|
|
6098
|
+
const text = getBeautifulRaw$1((body === null || body === void 0 ? void 0 : body.text) || "");
|
|
5912
6099
|
if ((body === null || body === void 0 ? void 0 : body.mimeType) === "multipart/form-data") {
|
|
5913
6100
|
bodyParams["mode"] = "form-data";
|
|
5914
6101
|
bodyParams["parameter"] = parameter;
|
|
@@ -6632,7 +6819,7 @@ class PostmanToApipost {
|
|
|
6632
6819
|
params["mode"] = "html";
|
|
6633
6820
|
break;
|
|
6634
6821
|
}
|
|
6635
|
-
params["raw"] = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? getBeautifulRaw(body === null || body === void 0 ? void 0 : body.raw) : "";
|
|
6822
|
+
params["raw"] = lodash.isString(body === null || body === void 0 ? void 0 : body.raw) ? getBeautifulRaw$1(body === null || body === void 0 ? void 0 : body.raw) : "";
|
|
6636
6823
|
if (apipostTools.isJson5(params["raw"])) {
|
|
6637
6824
|
try {
|
|
6638
6825
|
params.raw_schema = toJsonSchemasecond__default["default"](JSON5__default["default"].parse(params["raw"]));
|
|
@@ -7119,7 +7306,7 @@ class YapiToApipost {
|
|
|
7119
7306
|
}
|
|
7120
7307
|
else if ((item === null || item === void 0 ? void 0 : item.req_body_type) === "raw") {
|
|
7121
7308
|
body["mode"] = "json";
|
|
7122
|
-
body["raw"] = getBeautifulRaw((item === null || item === void 0 ? void 0 : item.req_body_other) || "");
|
|
7309
|
+
body["raw"] = getBeautifulRaw$1((item === null || item === void 0 ? void 0 : item.req_body_other) || "");
|
|
7123
7310
|
if (apipostTools.isJson(body["raw"])) {
|
|
7124
7311
|
try {
|
|
7125
7312
|
body["raw_schema"] = toJsonSchemasecond__default["default"](JSON5__default["default"].parse(body["raw"]));
|
|
@@ -7158,7 +7345,7 @@ class YapiToApipost {
|
|
|
7158
7345
|
};
|
|
7159
7346
|
if (lodash.has(item, "res_body_type")) {
|
|
7160
7347
|
if ((item === null || item === void 0 ? void 0 : item.res_body_type) === "raw") {
|
|
7161
|
-
raw = getBeautifulRaw((item === null || item === void 0 ? void 0 : item.res_body) || "");
|
|
7348
|
+
raw = getBeautifulRaw$1((item === null || item === void 0 ? void 0 : item.res_body) || "");
|
|
7162
7349
|
if (apipostTools.isJson(raw)) {
|
|
7163
7350
|
try {
|
|
7164
7351
|
schema = toJsonSchemasecond__default["default"](JSON5__default["default"].parse(raw));
|