echoapi-converter 0.0.44 → 0.0.45
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 +65 -59
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -771,6 +771,12 @@ const genUrlByQuery = (url, parameter, query_add_equal = 1) => {
|
|
|
771
771
|
newUrl = `${lodash.head(newUrl.split("?"))}${paramsStr ? "?" : ""}${paramsStr}${((_a = urlParse__default["default"](newUrl)) === null || _a === void 0 ? void 0 : _a.hash) || ""}`;
|
|
772
772
|
return newUrl;
|
|
773
773
|
};
|
|
774
|
+
const getSubstring = (str, length) => {
|
|
775
|
+
if (lodash.isString(str)) {
|
|
776
|
+
return str.substring(0, length);
|
|
777
|
+
}
|
|
778
|
+
return str;
|
|
779
|
+
};
|
|
774
780
|
|
|
775
781
|
// @ts-nocheck
|
|
776
782
|
class ApipostToSwagger {
|
|
@@ -1568,8 +1574,8 @@ class SwaggerToApipost {
|
|
|
1568
1574
|
}
|
|
1569
1575
|
}
|
|
1570
1576
|
handlePathV3(path, pathItem, tags) {
|
|
1577
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1571
1578
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1572
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1573
1579
|
let url = path;
|
|
1574
1580
|
for (const method in pathItem) {
|
|
1575
1581
|
const swaggerApi = pathItem[method];
|
|
@@ -1777,8 +1783,8 @@ class SwaggerToApipost {
|
|
|
1777
1783
|
raw: Raw_text,
|
|
1778
1784
|
raw_parameter: raw_parameter,
|
|
1779
1785
|
expect: {
|
|
1780
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
1781
|
-
code: status,
|
|
1786
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
1787
|
+
code: getSubstring(status, 128),
|
|
1782
1788
|
content_type: "json",
|
|
1783
1789
|
is_default: 1,
|
|
1784
1790
|
mock: "",
|
|
@@ -1793,8 +1799,8 @@ class SwaggerToApipost {
|
|
|
1793
1799
|
raw: Raw_text,
|
|
1794
1800
|
raw_parameter: raw_parameter,
|
|
1795
1801
|
expect: {
|
|
1796
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
1797
|
-
code: status,
|
|
1802
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
1803
|
+
code: getSubstring(status, 128),
|
|
1798
1804
|
content_type: "json",
|
|
1799
1805
|
is_default: -1,
|
|
1800
1806
|
mock: "",
|
|
@@ -1811,8 +1817,8 @@ class SwaggerToApipost {
|
|
|
1811
1817
|
raw: Raw_text,
|
|
1812
1818
|
raw_parameter: raw_parameter,
|
|
1813
1819
|
expect: {
|
|
1814
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
1815
|
-
code: status,
|
|
1820
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
1821
|
+
code: getSubstring(status, 128),
|
|
1816
1822
|
content_type: "json",
|
|
1817
1823
|
is_default: -1,
|
|
1818
1824
|
mock: "",
|
|
@@ -1864,8 +1870,8 @@ class SwaggerToApipost {
|
|
|
1864
1870
|
raw: Raw_text,
|
|
1865
1871
|
raw_parameter: [],
|
|
1866
1872
|
expect: {
|
|
1867
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
1868
|
-
code: status,
|
|
1873
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
1874
|
+
code: getSubstring(status, 128),
|
|
1869
1875
|
content_type: "json",
|
|
1870
1876
|
is_default: status == 200 ? 1 : -1,
|
|
1871
1877
|
mock: "",
|
|
@@ -1896,8 +1902,8 @@ class SwaggerToApipost {
|
|
|
1896
1902
|
raw: Raw_text,
|
|
1897
1903
|
raw_parameter: [],
|
|
1898
1904
|
expect: {
|
|
1899
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
1900
|
-
code: status,
|
|
1905
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
1906
|
+
code: getSubstring(status, 128),
|
|
1901
1907
|
content_type: "json",
|
|
1902
1908
|
is_default: -1,
|
|
1903
1909
|
mock: "",
|
|
@@ -1921,8 +1927,8 @@ class SwaggerToApipost {
|
|
|
1921
1927
|
raw: Raw_text,
|
|
1922
1928
|
raw_parameter: raw_parameter,
|
|
1923
1929
|
expect: {
|
|
1924
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
1925
|
-
code: status,
|
|
1930
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
1931
|
+
code: getSubstring(status, 128),
|
|
1926
1932
|
content_type: "json",
|
|
1927
1933
|
is_default: status == 200 ? 1 : -1,
|
|
1928
1934
|
mock: "",
|
|
@@ -1939,8 +1945,8 @@ class SwaggerToApipost {
|
|
|
1939
1945
|
raw: Raw_text,
|
|
1940
1946
|
raw_parameter: raw_parameter,
|
|
1941
1947
|
expect: {
|
|
1942
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
1943
|
-
code: status,
|
|
1948
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
1949
|
+
code: getSubstring(status, 128),
|
|
1944
1950
|
content_type: "json",
|
|
1945
1951
|
is_default: -1,
|
|
1946
1952
|
mock: "",
|
|
@@ -1959,8 +1965,8 @@ class SwaggerToApipost {
|
|
|
1959
1965
|
raw: "",
|
|
1960
1966
|
raw_parameter: [],
|
|
1961
1967
|
expect: {
|
|
1962
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status || "",
|
|
1963
|
-
code: status,
|
|
1968
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status || "", 255),
|
|
1969
|
+
code: getSubstring(status, 128),
|
|
1964
1970
|
content_type: "json",
|
|
1965
1971
|
is_default: -1,
|
|
1966
1972
|
mock: "",
|
|
@@ -1986,8 +1992,8 @@ class SwaggerToApipost {
|
|
|
1986
1992
|
});
|
|
1987
1993
|
}
|
|
1988
1994
|
handlePathsV3(json) {
|
|
1995
|
+
var _a, _b;
|
|
1989
1996
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1990
|
-
var _a, _b;
|
|
1991
1997
|
try {
|
|
1992
1998
|
const paths = ((_a = json === null || json === void 0 ? void 0 : json.openapi) === null || _a === void 0 ? void 0 : _a.paths) || json.paths;
|
|
1993
1999
|
const tags = ((_b = json === null || json === void 0 ? void 0 : json.openapi) === null || _b === void 0 ? void 0 : _b.tags) || json.tags;
|
|
@@ -2019,8 +2025,8 @@ class SwaggerToApipost {
|
|
|
2019
2025
|
}
|
|
2020
2026
|
}
|
|
2021
2027
|
handlePath(path, pathItem, tags) {
|
|
2028
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2022
2029
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2023
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2024
2030
|
let url = path;
|
|
2025
2031
|
url = decodeURI(this.basePath + url);
|
|
2026
2032
|
url = fixUrlPath(url);
|
|
@@ -2257,8 +2263,8 @@ class SwaggerToApipost {
|
|
|
2257
2263
|
raw: Raw_text,
|
|
2258
2264
|
raw_parameter: raw_parameter,
|
|
2259
2265
|
expect: {
|
|
2260
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
2261
|
-
code: status,
|
|
2266
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2267
|
+
code: getSubstring(status, 128),
|
|
2262
2268
|
content_type: "json",
|
|
2263
2269
|
is_default: 1,
|
|
2264
2270
|
mock: "",
|
|
@@ -2273,8 +2279,8 @@ class SwaggerToApipost {
|
|
|
2273
2279
|
raw: Raw_text,
|
|
2274
2280
|
raw_parameter: raw_parameter,
|
|
2275
2281
|
expect: {
|
|
2276
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
2277
|
-
code: status,
|
|
2282
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2283
|
+
code: getSubstring(status, 128),
|
|
2278
2284
|
content_type: "json",
|
|
2279
2285
|
is_default: -1,
|
|
2280
2286
|
mock: "",
|
|
@@ -2291,8 +2297,8 @@ class SwaggerToApipost {
|
|
|
2291
2297
|
raw: Raw_text,
|
|
2292
2298
|
raw_parameter: raw_parameter,
|
|
2293
2299
|
expect: {
|
|
2294
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
2295
|
-
code: status,
|
|
2300
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2301
|
+
code: getSubstring(status, 128),
|
|
2296
2302
|
content_type: "json",
|
|
2297
2303
|
is_default: -1,
|
|
2298
2304
|
mock: "",
|
|
@@ -2326,8 +2332,8 @@ class SwaggerToApipost {
|
|
|
2326
2332
|
raw: Raw_text,
|
|
2327
2333
|
raw_parameter: raw_parameter,
|
|
2328
2334
|
expect: {
|
|
2329
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
2330
|
-
code: status,
|
|
2335
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2336
|
+
code: getSubstring(status, 128),
|
|
2331
2337
|
content_type: "json",
|
|
2332
2338
|
is_default: 1,
|
|
2333
2339
|
mock: "",
|
|
@@ -2342,8 +2348,8 @@ class SwaggerToApipost {
|
|
|
2342
2348
|
raw: Raw_text,
|
|
2343
2349
|
raw_parameter: raw_parameter,
|
|
2344
2350
|
expect: {
|
|
2345
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
2346
|
-
code: status,
|
|
2351
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2352
|
+
code: getSubstring(status, 128),
|
|
2347
2353
|
content_type: "json",
|
|
2348
2354
|
is_default: -1,
|
|
2349
2355
|
mock: "",
|
|
@@ -2360,8 +2366,8 @@ class SwaggerToApipost {
|
|
|
2360
2366
|
raw: Raw_text,
|
|
2361
2367
|
raw_parameter: raw_parameter,
|
|
2362
2368
|
expect: {
|
|
2363
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
2364
|
-
code: status,
|
|
2369
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2370
|
+
code: getSubstring(status, 128),
|
|
2365
2371
|
content_type: "json",
|
|
2366
2372
|
is_default: -1,
|
|
2367
2373
|
mock: "",
|
|
@@ -2386,8 +2392,8 @@ class SwaggerToApipost {
|
|
|
2386
2392
|
raw: "",
|
|
2387
2393
|
raw_parameter: [],
|
|
2388
2394
|
expect: {
|
|
2389
|
-
name: (element === null || element === void 0 ? void 0 : element.description) || status,
|
|
2390
|
-
code: status,
|
|
2395
|
+
name: getSubstring((element === null || element === void 0 ? void 0 : element.description) || status, 255),
|
|
2396
|
+
code: getSubstring(status, 128),
|
|
2391
2397
|
content_type: "json",
|
|
2392
2398
|
is_default: -1,
|
|
2393
2399
|
mock: "",
|
|
@@ -2427,8 +2433,8 @@ class SwaggerToApipost {
|
|
|
2427
2433
|
catch (err) { }
|
|
2428
2434
|
});
|
|
2429
2435
|
}
|
|
2430
|
-
convert(
|
|
2431
|
-
return __awaiter(this,
|
|
2436
|
+
convert(json, options = null) {
|
|
2437
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
2432
2438
|
this.clear();
|
|
2433
2439
|
try {
|
|
2434
2440
|
if (options && options instanceof Object) {
|
|
@@ -2755,7 +2761,7 @@ class ApidocToApipost {
|
|
|
2755
2761
|
project_id: this.project.project_id || "",
|
|
2756
2762
|
parent_id: "0",
|
|
2757
2763
|
target_type: "folder",
|
|
2758
|
-
name: (item === null || item === void 0 ? void 0 : item.group) || "New Folder",
|
|
2764
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.group, 255) || "New Folder",
|
|
2759
2765
|
version: 0,
|
|
2760
2766
|
sort: 0,
|
|
2761
2767
|
description: (item === null || item === void 0 ? void 0 : item.groupTitle) || "",
|
|
@@ -2771,7 +2777,7 @@ class ApidocToApipost {
|
|
|
2771
2777
|
project_id: this.project.project_id || "",
|
|
2772
2778
|
parent_id: id || "0",
|
|
2773
2779
|
target_type: "api",
|
|
2774
|
-
name: (item === null || item === void 0 ? void 0 : item.title) || "New HTTP",
|
|
2780
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.title, 255) || "New HTTP",
|
|
2775
2781
|
version: 0,
|
|
2776
2782
|
sort: 0,
|
|
2777
2783
|
description: (item === null || item === void 0 ? void 0 : item.description) || "",
|
|
@@ -2996,8 +3002,8 @@ class ApifoxToApipost {
|
|
|
2996
3002
|
}
|
|
2997
3003
|
initProject(json, project_id) {
|
|
2998
3004
|
var _a, _b;
|
|
2999
|
-
this.project.name = ((_a = json === null || json === void 0 ? void 0 : json.info) === null || _a === void 0 ? void 0 : _a.name) || "New Project";
|
|
3000
|
-
this.project.intro = ((_b = json === null || json === void 0 ? void 0 : json.info) === null || _b === void 0 ? void 0 : _b.description) || "";
|
|
3005
|
+
this.project.name = getSubstring((_a = json === null || json === void 0 ? void 0 : json.info) === null || _a === void 0 ? void 0 : _a.name, 64) || "New Project";
|
|
3006
|
+
this.project.intro = getSubstring((_b = json === null || json === void 0 ? void 0 : json.info) === null || _b === void 0 ? void 0 : _b.description, 1024) || "";
|
|
3001
3007
|
this.project.project_id = project_id;
|
|
3002
3008
|
}
|
|
3003
3009
|
completionParameter(parameter) {
|
|
@@ -3566,7 +3572,7 @@ class ApifoxToApipost {
|
|
|
3566
3572
|
project_id: this.project.project_id || "",
|
|
3567
3573
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
|
|
3568
3574
|
target_type: "folder",
|
|
3569
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || "New Folder",
|
|
3575
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "New Folder",
|
|
3570
3576
|
version: 0,
|
|
3571
3577
|
sort: 0,
|
|
3572
3578
|
description: (item === null || item === void 0 ? void 0 : item.description) || "",
|
|
@@ -3602,9 +3608,9 @@ class ApifoxToApipost {
|
|
|
3602
3608
|
raw: raw ? getBeautifulRaw((raw === null || raw === void 0 ? void 0 : raw.data) || "") : "",
|
|
3603
3609
|
raw_parameter: [],
|
|
3604
3610
|
expect: {
|
|
3605
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || "",
|
|
3611
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "",
|
|
3606
3612
|
is_default: index === 0 ? 1 : -1,
|
|
3607
|
-
code: (item === null || item === void 0 ? void 0 : item.code) && lodash.isNumber(item === null || item === void 0 ? void 0 : item.code) ? String(item === null || item === void 0 ? void 0 : item.code) : "",
|
|
3613
|
+
code: (item === null || item === void 0 ? void 0 : item.code) && lodash.isNumber(item === null || item === void 0 ? void 0 : item.code) ? getSubstring(String(item === null || item === void 0 ? void 0 : item.code), 128) : "",
|
|
3608
3614
|
content_type: (DEFAULT_CONTENT_TYPE === null || DEFAULT_CONTENT_TYPE === void 0 ? void 0 : DEFAULT_CONTENT_TYPE.includes(item === null || item === void 0 ? void 0 : item.contentType))
|
|
3609
3615
|
? item === null || item === void 0 ? void 0 : item.contentType
|
|
3610
3616
|
: "json",
|
|
@@ -3643,16 +3649,16 @@ class ApifoxToApipost {
|
|
|
3643
3649
|
if (((_a = api === null || api === void 0 ? void 0 : api.requestBody) === null || _a === void 0 ? void 0 : _a.type) === 'graphql') {
|
|
3644
3650
|
const request = this.completionApiRequest(Object.assign(Object.assign({}, api === null || api === void 0 ? void 0 : api.parameters), { preProcessors: api === null || api === void 0 ? void 0 : api.preProcessors, postProcessors: api === null || api === void 0 ? void 0 : api.postProcessors, auth: api === null || api === void 0 ? void 0 : api.auth }), api === null || api === void 0 ? void 0 : api.requestBody);
|
|
3645
3651
|
const body = this.completionGraphqlRequestBody(api === null || api === void 0 ? void 0 : api.requestBody);
|
|
3646
|
-
return Object.assign(Object.assign({}, baseInfo), { parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0", target_type: "graphql", name: (item === null || item === void 0 ? void 0 : item.name) || "New GraphQL", version: 0, sort: 0, description: (api === null || api === void 0 ? void 0 : api.description) || "", url: (api === null || api === void 0 ? void 0 : api.path) || "", mark_id: this.completionApiTargetMark(api === null || api === void 0 ? void 0 : api.status), request: Object.assign(Object.assign({}, lodash.omit(request, ['body', 'query', 'restful'])), { body }), response: this.completionApiResponse(api === null || api === void 0 ? void 0 : api.responses, api === null || api === void 0 ? void 0 : api.responseExamples), attribute_info: {}, tags: isArray(api === null || api === void 0 ? void 0 : api.tags) ? api === null || api === void 0 ? void 0 : api.tags : [], is_force: -1 });
|
|
3652
|
+
return Object.assign(Object.assign({}, baseInfo), { parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0", target_type: "graphql", name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "New GraphQL", version: 0, sort: 0, description: (api === null || api === void 0 ? void 0 : api.description) || "", url: (api === null || api === void 0 ? void 0 : api.path) || "", mark_id: this.completionApiTargetMark(api === null || api === void 0 ? void 0 : api.status), request: Object.assign(Object.assign({}, lodash.omit(request, ['body', 'query', 'restful'])), { body }), response: this.completionApiResponse(api === null || api === void 0 ? void 0 : api.responses, api === null || api === void 0 ? void 0 : api.responseExamples), attribute_info: {}, tags: isArray(api === null || api === void 0 ? void 0 : api.tags) ? api === null || api === void 0 ? void 0 : api.tags : [], is_force: -1 });
|
|
3647
3653
|
}
|
|
3648
|
-
return Object.assign(Object.assign({}, baseInfo), { parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0", target_type: "api", name: (item === null || item === void 0 ? void 0 : item.name) || "New HTTP", version: 0, sort: 0, description: (api === null || api === void 0 ? void 0 : api.description) || "", method: (api === null || api === void 0 ? void 0 : api.method) ? (_b = api === null || api === void 0 ? void 0 : api.method) === null || _b === void 0 ? void 0 : _b.toUpperCase() : "GET", url: (api === null || api === void 0 ? void 0 : api.path) || "", mark_id: this.completionApiTargetMark(api === null || api === void 0 ? void 0 : api.status), protocol: "http/1.1", request: this.completionApiRequest(Object.assign(Object.assign({}, api === null || api === void 0 ? void 0 : api.parameters), { preProcessors: api === null || api === void 0 ? void 0 : api.preProcessors, postProcessors: api === null || api === void 0 ? void 0 : api.postProcessors, auth: api === null || api === void 0 ? void 0 : api.auth }), api === null || api === void 0 ? void 0 : api.requestBody), response: this.completionApiResponse(api === null || api === void 0 ? void 0 : api.responses, api === null || api === void 0 ? void 0 : api.responseExamples), attribute_info: {}, tags: isArray(api === null || api === void 0 ? void 0 : api.tags) ? api === null || api === void 0 ? void 0 : api.tags : [], is_force: -1 });
|
|
3654
|
+
return Object.assign(Object.assign({}, baseInfo), { parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0", target_type: "api", name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "New HTTP", version: 0, sort: 0, description: (api === null || api === void 0 ? void 0 : api.description) || "", method: (api === null || api === void 0 ? void 0 : api.method) ? (_b = api === null || api === void 0 ? void 0 : api.method) === null || _b === void 0 ? void 0 : _b.toUpperCase() : "GET", url: (api === null || api === void 0 ? void 0 : api.path) || "", mark_id: this.completionApiTargetMark(api === null || api === void 0 ? void 0 : api.status), protocol: "http/1.1", request: this.completionApiRequest(Object.assign(Object.assign({}, api === null || api === void 0 ? void 0 : api.parameters), { preProcessors: api === null || api === void 0 ? void 0 : api.preProcessors, postProcessors: api === null || api === void 0 ? void 0 : api.postProcessors, auth: api === null || api === void 0 ? void 0 : api.auth }), api === null || api === void 0 ? void 0 : api.requestBody), response: this.completionApiResponse(api === null || api === void 0 ? void 0 : api.responses, api === null || api === void 0 ? void 0 : api.responseExamples), attribute_info: {}, tags: isArray(api === null || api === void 0 ? void 0 : api.tags) ? api === null || api === void 0 ? void 0 : api.tags : [], is_force: -1 });
|
|
3649
3655
|
}
|
|
3650
3656
|
completionApiSample(item, baseInfo) {
|
|
3651
3657
|
const { api } = item || {};
|
|
3652
3658
|
const { cases } = api || {};
|
|
3653
3659
|
return cases === null || cases === void 0 ? void 0 : cases.map((caseItem) => {
|
|
3654
3660
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
3655
|
-
return Object.assign(Object.assign({}, baseInfo), { created_at: 0, method: (api === null || api === void 0 ? void 0 : api.method) ? (_a = api === null || api === void 0 ? void 0 : api.method) === null || _a === void 0 ? void 0 : _a.toUpperCase() : "GET", name: (caseItem === null || caseItem === void 0 ? void 0 : caseItem.name) || "New Test Case", parent_id: "0", protocol: "http/1.1", request: this.completionApiRequest({
|
|
3661
|
+
return Object.assign(Object.assign({}, baseInfo), { created_at: 0, method: (api === null || api === void 0 ? void 0 : api.method) ? (_a = api === null || api === void 0 ? void 0 : api.method) === null || _a === void 0 ? void 0 : _a.toUpperCase() : "GET", name: getSubstring(caseItem === null || caseItem === void 0 ? void 0 : caseItem.name, 255) || "New Test Case", parent_id: "0", protocol: "http/1.1", request: this.completionApiRequest({
|
|
3656
3662
|
header: (_c = (((_b = caseItem === null || caseItem === void 0 ? void 0 : caseItem.parameters) === null || _b === void 0 ? void 0 : _b.header) || [])) === null || _c === void 0 ? void 0 : _c.concat(((_d = api === null || api === void 0 ? void 0 : api.parameters) === null || _d === void 0 ? void 0 : _d.header) || []),
|
|
3657
3663
|
query: (_f = (((_e = caseItem === null || caseItem === void 0 ? void 0 : caseItem.parameters) === null || _e === void 0 ? void 0 : _e.query) || [])) === null || _f === void 0 ? void 0 : _f.concat(((_g = api === null || api === void 0 ? void 0 : api.parameters) === null || _g === void 0 ? void 0 : _g.query) || []),
|
|
3658
3664
|
cookie: (_j = (((_h = caseItem === null || caseItem === void 0 ? void 0 : caseItem.parameters) === null || _h === void 0 ? void 0 : _h.cookie) || [])) === null || _j === void 0 ? void 0 : _j.concat(((_k = api === null || api === void 0 ? void 0 : api.parameters) === null || _k === void 0 ? void 0 : _k.cookie) || []),
|
|
@@ -4939,7 +4945,7 @@ class HarToApipost {
|
|
|
4939
4945
|
project_id: this.project.project_id || "",
|
|
4940
4946
|
parent_id: "0",
|
|
4941
4947
|
target_type: "api",
|
|
4942
|
-
name: url || "New HTTP",
|
|
4948
|
+
name: getSubstring(url, 255) || "New HTTP",
|
|
4943
4949
|
version: 0,
|
|
4944
4950
|
sort: 0,
|
|
4945
4951
|
description: "",
|
|
@@ -5033,8 +5039,8 @@ class InsomniaToApipost {
|
|
|
5033
5039
|
}
|
|
5034
5040
|
initProject(resources, project_id) {
|
|
5035
5041
|
const projectInfo = resources === null || resources === void 0 ? void 0 : resources.find((e) => (e === null || e === void 0 ? void 0 : e._type) === "workspace");
|
|
5036
|
-
this.project.name = (projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.name) || "New Project";
|
|
5037
|
-
this.project.intro = (projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.description) || "";
|
|
5042
|
+
this.project.name = getSubstring(projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.name, 64) || "New Project";
|
|
5043
|
+
this.project.intro = getSubstring(projectInfo === null || projectInfo === void 0 ? void 0 : projectInfo.description, 1024) || "";
|
|
5038
5044
|
this.project.project_id = project_id;
|
|
5039
5045
|
}
|
|
5040
5046
|
completionParameter(parameter) {
|
|
@@ -5235,7 +5241,7 @@ class InsomniaToApipost {
|
|
|
5235
5241
|
parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
|
|
5236
5242
|
description: (item === null || item === void 0 ? void 0 : item.description) || '',
|
|
5237
5243
|
target_type: "websocket2",
|
|
5238
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || "New Websocket",
|
|
5244
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "New Websocket",
|
|
5239
5245
|
sort: 0,
|
|
5240
5246
|
version: 0,
|
|
5241
5247
|
mark_id: "1",
|
|
@@ -5292,7 +5298,7 @@ class InsomniaToApipost {
|
|
|
5292
5298
|
project_id: this.project.project_id || "",
|
|
5293
5299
|
parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
|
|
5294
5300
|
target_type: "graphql",
|
|
5295
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || "New GraphQL",
|
|
5301
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "New GraphQL",
|
|
5296
5302
|
version: 0,
|
|
5297
5303
|
sort: 0,
|
|
5298
5304
|
description: (item === null || item === void 0 ? void 0 : item.description) || "",
|
|
@@ -5350,7 +5356,7 @@ class InsomniaToApipost {
|
|
|
5350
5356
|
project_id: this.project.project_id || "",
|
|
5351
5357
|
parent_id: ((_a = this.foldersMap) === null || _a === void 0 ? void 0 : _a[item === null || item === void 0 ? void 0 : item.parentId]) || "0",
|
|
5352
5358
|
target_type: "api",
|
|
5353
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || "New HTTP",
|
|
5359
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "New HTTP",
|
|
5354
5360
|
version: 0,
|
|
5355
5361
|
sort: 0,
|
|
5356
5362
|
description: (item === null || item === void 0 ? void 0 : item.description) || "",
|
|
@@ -5426,7 +5432,7 @@ class InsomniaToApipost {
|
|
|
5426
5432
|
project_id: this.project.project_id || "",
|
|
5427
5433
|
parent_id: this.foldersMap[item === null || item === void 0 ? void 0 : item.parentId] || "0",
|
|
5428
5434
|
target_type: "folder",
|
|
5429
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || "New Folder",
|
|
5435
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "New Folder",
|
|
5430
5436
|
version: 0,
|
|
5431
5437
|
sort: 0,
|
|
5432
5438
|
description: (item === null || item === void 0 ? void 0 : item.description) || "",
|
|
@@ -5905,7 +5911,7 @@ class PostmanToApipost {
|
|
|
5905
5911
|
project_id: this.project.project_id || "",
|
|
5906
5912
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
|
|
5907
5913
|
target_type: "folder",
|
|
5908
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || "New Folder",
|
|
5914
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "New Folder",
|
|
5909
5915
|
version: 0,
|
|
5910
5916
|
sort: 0,
|
|
5911
5917
|
description: (item === null || item === void 0 ? void 0 : item.description) || "",
|
|
@@ -5925,7 +5931,7 @@ class PostmanToApipost {
|
|
|
5925
5931
|
project_id: this.project.project_id || "",
|
|
5926
5932
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
|
|
5927
5933
|
target_type: "graphql",
|
|
5928
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || "New GraphQL",
|
|
5934
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "New GraphQL",
|
|
5929
5935
|
version: 0,
|
|
5930
5936
|
sort: 0,
|
|
5931
5937
|
description: (item === null || item === void 0 ? void 0 : item.description) || "",
|
|
@@ -5984,7 +5990,7 @@ class PostmanToApipost {
|
|
|
5984
5990
|
project_id: this.project.project_id || "",
|
|
5985
5991
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
|
|
5986
5992
|
target_type: "api",
|
|
5987
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || "New HTTP",
|
|
5993
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "New HTTP",
|
|
5988
5994
|
version: 0,
|
|
5989
5995
|
sort: 0,
|
|
5990
5996
|
description: (item === null || item === void 0 ? void 0 : item.description) || "",
|
|
@@ -6066,8 +6072,8 @@ class PostmanToApipost {
|
|
|
6066
6072
|
}
|
|
6067
6073
|
initProject(json, project_id) {
|
|
6068
6074
|
var _a, _b;
|
|
6069
|
-
this.project.name = ((_a = json === null || json === void 0 ? void 0 : json.info) === null || _a === void 0 ? void 0 : _a.name) || "New Project";
|
|
6070
|
-
this.project.intro = ((_b = json === null || json === void 0 ? void 0 : json.info) === null || _b === void 0 ? void 0 : _b.description) || "";
|
|
6075
|
+
this.project.name = getSubstring((_a = json === null || json === void 0 ? void 0 : json.info) === null || _a === void 0 ? void 0 : _a.name, 64) || "New Project";
|
|
6076
|
+
this.project.intro = getSubstring((_b = json === null || json === void 0 ? void 0 : json.info) === null || _b === void 0 ? void 0 : _b.description, 1024) || "";
|
|
6071
6077
|
this.project.project_id = project_id;
|
|
6072
6078
|
}
|
|
6073
6079
|
convert(json, project_id, option) {
|
|
@@ -6126,7 +6132,7 @@ class YapiToApipost {
|
|
|
6126
6132
|
project_id: this.project.project_id || "",
|
|
6127
6133
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
|
|
6128
6134
|
target_type: "folder",
|
|
6129
|
-
name: (item === null || item === void 0 ? void 0 : item.name) || "New Folder",
|
|
6135
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.name, 255) || "New Folder",
|
|
6130
6136
|
version: 0,
|
|
6131
6137
|
sort: 0,
|
|
6132
6138
|
description: (item === null || item === void 0 ? void 0 : item.description) || "",
|
|
@@ -6298,7 +6304,7 @@ class YapiToApipost {
|
|
|
6298
6304
|
project_id: this.project.project_id || "",
|
|
6299
6305
|
parent_id: (parentInfo === null || parentInfo === void 0 ? void 0 : parentInfo.target_id) || "0",
|
|
6300
6306
|
target_type: "api",
|
|
6301
|
-
name: (item === null || item === void 0 ? void 0 : item.title) || "New HTTP",
|
|
6307
|
+
name: getSubstring(item === null || item === void 0 ? void 0 : item.title, 255) || "New HTTP",
|
|
6302
6308
|
version: 0,
|
|
6303
6309
|
sort: 0,
|
|
6304
6310
|
description: (item === null || item === void 0 ? void 0 : item.desc) || "",
|