echoapi-converter 0.0.83 → 0.0.84

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -280,4 +280,18 @@ declare class ThunderToApipost {
280
280
  };
281
281
  }
282
282
 
283
- export { ApipostToSwagger as ApiToSwagger, ApidocToApipost, ApifoxToApipost, ApipostToPostman, HarToApipost, InsomniaToApipost, PostmanToApipost, SwaggerToApipost, ThunderToApipost, YapiToApipost };
283
+ type ImportConfig = {
284
+ mode: string;
285
+ folder_id: string;
286
+ host?: string;
287
+ base_path?: string;
288
+ api_cover_modal: string;
289
+ model_cover_modal: string;
290
+ env_cover_modal: string;
291
+ };
292
+
293
+ declare const swaggerConverFormat: (json: any, baseConfig: ImportConfig, project_id: string) => {
294
+ global: {};
295
+ };
296
+
297
+ export { ApipostToSwagger as ApiToSwagger, ApidocToApipost, ApifoxToApipost, ApipostToPostman, HarToApipost, InsomniaToApipost, PostmanToApipost, swaggerConverFormat as SwaggerConverFormat, SwaggerToApipost, ThunderToApipost, YapiToApipost };
package/dist/index.js CHANGED
@@ -633,6 +633,32 @@ const getSubstring = (str, length) => {
633
633
  return str;
634
634
  };
635
635
 
636
+ const DEFAULT_RESPONSE = {
637
+ example_id: '1',
638
+ raw: '',
639
+ raw_parameter: [],
640
+ headers: [], // 新headers
641
+ expect: {
642
+ name: '成功',
643
+ is_default: -1,
644
+ code: '200',
645
+ sleep: 0, // 新sleep
646
+ content_type: 'json',
647
+ verify_type: 'schema',
648
+ mock: '',
649
+ schema: {
650
+ type: 'object',
651
+ properties: {},
652
+ },
653
+ },
654
+ };
655
+ const SUCCESS_RESPONSE = Object.assign(Object.assign({}, DEFAULT_RESPONSE), { example_id: '1', expect: Object.assign(Object.assign({}, DEFAULT_RESPONSE.expect), { name: '成功', is_default: 1, code: '200' }) });
656
+ const ERROR_RESPONSE = Object.assign(Object.assign({}, DEFAULT_RESPONSE), { example_id: '2', expect: Object.assign(Object.assign({}, DEFAULT_RESPONSE.expect), { name: '失败', is_default: -1, code: '404' }) });
657
+ const DEFAULT_API_RESPONSE = {
658
+ is_check_result: 1,
659
+ example: [SUCCESS_RESPONSE, ERROR_RESPONSE],
660
+ };
661
+
636
662
  const getApipostMode = (mode) => {
637
663
  let apipostMode = 'none';
638
664
  if (mode == 'multipart/form-data') {
@@ -717,7 +743,6 @@ const handleBodyJsonSchema = (schema, raw_para, pre = '', requiredArr = [], prop
717
743
  }
718
744
  else if (itemsType === "integer") {
719
745
  let value = ((_t = (_s = (_r = schema === null || schema === void 0 ? void 0 : schema.items) === null || _r === void 0 ? void 0 : _r.oneOf) === null || _s === void 0 ? void 0 : _s[0]) === null || _t === void 0 ? void 0 : _t.example) || ((_u = schema === null || schema === void 0 ? void 0 : schema.items) === null || _u === void 0 ? void 0 : _u.example) || 0;
720
- // console.log(value,"valuevalue");
721
746
  if (Object.prototype.toString.call(raw_para) === '[object Array]') {
722
747
  raw_para.push({
723
748
  key: `${pre}.0`,
@@ -1071,7 +1096,7 @@ const completionResponse = (responses) => {
1071
1096
  const example = [];
1072
1097
  if (lodash.isPlainObject(responses)) {
1073
1098
  Object.keys(responses).forEach((status) => {
1074
- var _a, _b, _c, _d;
1099
+ var _a, _b, _c, _d, _e;
1075
1100
  const element = responses[status];
1076
1101
  if ((lodash.has(element, "schema") &&
1077
1102
  lodash.has(element.schema, "properties") &&
@@ -1155,29 +1180,30 @@ const completionResponse = (responses) => {
1155
1180
  if (lodash.has(schema, "properties")) ;
1156
1181
  if (lodash.has(schema, "items")) ;
1157
1182
  }
1158
- if (apipostMode == "json") {
1183
+ if (apipostMode == "json" || apipostMode === "*/*") {
1159
1184
  let jsonSchema = {};
1160
- 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]") {
1185
+ 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]" ||
1186
+ Object.prototype.toString.call((_e = bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema) === null || _e === void 0 ? void 0 : _e["$ref"]) === "[object String]") {
1161
1187
  jsonSchema = swaggerSchema2apipostSchema(bodyData.schema);
1162
1188
  }
1163
1189
  else if (lodash.isPlainObject(bodyData === null || bodyData === void 0 ? void 0 : bodyData.schema)) {
1164
1190
  jsonSchema = bodyData.schema;
1165
1191
  }
1166
1192
  if (lodash.has(bodyData, "example")) {
1167
- const example = bodyData.example;
1193
+ const exampleRaw = bodyData.example;
1168
1194
  if (status == 200 || status == 404) {
1169
1195
  let originRaw;
1170
1196
  try {
1171
- if (Object.prototype.toString.call(example) ===
1197
+ if (Object.prototype.toString.call(exampleRaw) ===
1172
1198
  "[object Object]") {
1173
- originRaw = JSON.stringify(Object.assign({}, example));
1199
+ originRaw = JSON.stringify(Object.assign({}, exampleRaw));
1174
1200
  }
1175
1201
  else {
1176
- originRaw = String(example);
1202
+ originRaw = String(exampleRaw);
1177
1203
  }
1178
1204
  }
1179
1205
  catch (error) {
1180
- originRaw = String(example);
1206
+ originRaw = String(exampleRaw);
1181
1207
  }
1182
1208
  const Raw_text = getBeautifulRaw(originRaw);
1183
1209
  example.push({
@@ -1200,16 +1226,16 @@ const completionResponse = (responses) => {
1200
1226
  const newUUID = apipostTools.snowflakeId();
1201
1227
  let originRaw;
1202
1228
  try {
1203
- if (Object.prototype.toString.call(example) ===
1229
+ if (Object.prototype.toString.call(exampleRaw) ===
1204
1230
  "[object Object]") {
1205
- originRaw = JSON.stringify(Object.assign({}, example));
1231
+ originRaw = JSON.stringify(Object.assign({}, exampleRaw));
1206
1232
  }
1207
1233
  else {
1208
- originRaw = example;
1234
+ originRaw = exampleRaw;
1209
1235
  }
1210
1236
  }
1211
1237
  catch (error) {
1212
- originRaw = String(example);
1238
+ originRaw = String(exampleRaw);
1213
1239
  }
1214
1240
  const Raw_text = getBeautifulRaw(originRaw);
1215
1241
  example.push({
@@ -1465,6 +1491,254 @@ const completionSocketMethodRequest = (swaggerApi) => {
1465
1491
  },
1466
1492
  };
1467
1493
  };
1494
+ const completionConfig = (res, config, baseConfig) => {
1495
+ var _a;
1496
+ res['config'] = Object.assign(Object.assign({}, baseConfig), { host: config.host, base_path: config.base_path });
1497
+ (_a = res === null || res === void 0 ? void 0 : res.config) === null || _a === void 0 ? true : delete _a.mode;
1498
+ };
1499
+ const completionProject = (res, project, project_id) => {
1500
+ res['name'] = project.name;
1501
+ res['project_id'] = project_id;
1502
+ res['intro'] = project.description;
1503
+ };
1504
+ const completionSwaggerEnv = (res, env) => {
1505
+ res['global']['envs'] = env === null || env === void 0 ? void 0 : env.map(({ name, env_var_list, url }) => ({
1506
+ env_id: apipostTools.snowflakeId(),
1507
+ name,
1508
+ is_private: -1,
1509
+ env_var_list: env_var_list || {},
1510
+ server_list: url
1511
+ ? [{ name: '默认服务', server_id: '1', uri: url }]
1512
+ : undefined,
1513
+ }));
1514
+ };
1515
+ const ApiItemInit = (res, apis, parent_id = '0', project_id) => {
1516
+ if (lodash.isArray(apis) && apis.length) {
1517
+ apis.forEach(({ name, target_type, tags, url, method, description, response, request, children, mark_id, }) => {
1518
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1519
+ const targetItem = {
1520
+ target_type,
1521
+ description,
1522
+ mark_id: mark_id || '1',
1523
+ request: {
1524
+ auth: DEFAULT_AUTH,
1525
+ pre_tasks: [],
1526
+ post_tasks: [],
1527
+ header: {
1528
+ parameter: ((_a = request === null || request === void 0 ? void 0 : request.header) === null || _a === void 0 ? void 0 : _a.parameter) || [],
1529
+ },
1530
+ query: {
1531
+ parameter: ((_b = request === null || request === void 0 ? void 0 : request.query) === null || _b === void 0 ? void 0 : _b.parameter) || [],
1532
+ },
1533
+ cookie: {
1534
+ parameter: ((_c = request === null || request === void 0 ? void 0 : request.cookie) === null || _c === void 0 ? void 0 : _c.parameter) || [],
1535
+ },
1536
+ restful: {
1537
+ parameter: ((_d = request === null || request === void 0 ? void 0 : request.restful) === null || _d === void 0 ? void 0 : _d.parameter) || [],
1538
+ },
1539
+ },
1540
+ ai_expect_enable: -1,
1541
+ is_check_result: 1,
1542
+ is_socket: 1,
1543
+ is_locked: -1,
1544
+ is_force: -1,
1545
+ attribute_info: {},
1546
+ protocol: 'http/1.1',
1547
+ ai_expect: {
1548
+ list: [],
1549
+ none_math_expect_id: '1',
1550
+ },
1551
+ project_id,
1552
+ target_id: apipostTools.snowflakeId(),
1553
+ parent_id,
1554
+ sort: 0,
1555
+ version: 0,
1556
+ server_id: '0',
1557
+ status: 1,
1558
+ is_changed: -1,
1559
+ };
1560
+ if (target_type === 'api') {
1561
+ targetItem['name'] = getSubstring(name, 255) || '新建接口';
1562
+ targetItem['tags'] = tags || [];
1563
+ targetItem['url'] = url || '';
1564
+ targetItem['method'] = method || '';
1565
+ targetItem['request'] = Object.assign(Object.assign({}, targetItem['request']), { body: {
1566
+ mode: ((_e = request === null || request === void 0 ? void 0 : request.body) === null || _e === void 0 ? void 0 : _e.mode) || 'none',
1567
+ parameter: ((_f = request === null || request === void 0 ? void 0 : request.body) === null || _f === void 0 ? void 0 : _f.parameter) || [],
1568
+ raw: ((_g = request === null || request === void 0 ? void 0 : request.body) === null || _g === void 0 ? void 0 : _g.raw) || '',
1569
+ raw_parameter: ((_h = request === null || request === void 0 ? void 0 : request.body) === null || _h === void 0 ? void 0 : _h.raw_parameter) || [],
1570
+ raw_schema: ((_j = request === null || request === void 0 ? void 0 : request.body) === null || _j === void 0 ? void 0 : _j.raw_schema) || { type: 'object' },
1571
+ binary: null,
1572
+ } });
1573
+ targetItem['response'] = Object.assign(Object.assign({}, DEFAULT_API_RESPONSE), response);
1574
+ if (!((_k = response === null || response === void 0 ? void 0 : response.example) === null || _k === void 0 ? void 0 : _k.find((e) => (e === null || e === void 0 ? void 0 : e.example_id) === '2'))) {
1575
+ (_l = targetItem['response']) === null || _l === void 0 ? void 0 : _l.example.unshift(ERROR_RESPONSE);
1576
+ }
1577
+ if (!((_m = response === null || response === void 0 ? void 0 : response.example) === null || _m === void 0 ? void 0 : _m.find((e) => (e === null || e === void 0 ? void 0 : e.example_id) === '1'))) {
1578
+ (_o = targetItem['response']) === null || _o === void 0 ? void 0 : _o.example.unshift(SUCCESS_RESPONSE);
1579
+ }
1580
+ // 通过query重新生成url
1581
+ if (targetItem.url && lodash.isArray((_q = (_p = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _p === void 0 ? void 0 : _p.query) === null || _q === void 0 ? void 0 : _q.parameter)) {
1582
+ const newUrl = genUrlByQuery(targetItem.url, (_s = (_r = targetItem === null || targetItem === void 0 ? void 0 : targetItem.request) === null || _r === void 0 ? void 0 : _r.query) === null || _s === void 0 ? void 0 : _s.parameter);
1583
+ targetItem.url = newUrl;
1584
+ }
1585
+ res.apis.push(targetItem);
1586
+ if (lodash.isArray(children) && children.length) {
1587
+ ApiItemInit(res, children, targetItem.target_id, project_id);
1588
+ }
1589
+ }
1590
+ else if (target_type === 'folder') {
1591
+ targetItem['name'] = getSubstring(name, 255) || '新建目录';
1592
+ targetItem['request'] = Object.assign(Object.assign({}, targetItem['request']), { body: {
1593
+ parameter: ((_t = request === null || request === void 0 ? void 0 : request.body) === null || _t === void 0 ? void 0 : _t.parameter) || [],
1594
+ } });
1595
+ res.apis.push(targetItem);
1596
+ if (lodash.isArray(children) && children.length) {
1597
+ ApiItemInit(res, children, targetItem.target_id, project_id);
1598
+ }
1599
+ }
1600
+ });
1601
+ }
1602
+ };
1603
+ const ModelItemInit = (res, dataModel, parent_id = '0', project_id) => {
1604
+ if (lodash.isArray(dataModel) && dataModel.length) {
1605
+ // createModel(dataModel, newJson, '0');
1606
+ dataModel.forEach((model) => {
1607
+ let model_type = 'model';
1608
+ if (lodash.has(model, 'model_type')) {
1609
+ if (model.model_type == 'folder' ||
1610
+ (lodash.has(model, 'children') && model.children instanceof Array)) {
1611
+ model_type = 'folder';
1612
+ }
1613
+ }
1614
+ try {
1615
+ const hashIndex = model === null || model === void 0 ? void 0 : model.model_id.indexOf('#');
1616
+ if (hashIndex !== -1) {
1617
+ model.model_id = model.model_id.substring(hashIndex);
1618
+ }
1619
+ }
1620
+ catch (error) { }
1621
+ const new_model_id = apipostTools.snowflakeId();
1622
+ const target = {
1623
+ model_id: new_model_id,
1624
+ old_model_id: (model === null || model === void 0 ? void 0 : model.model_id) || '',
1625
+ model_type,
1626
+ description: (model === null || model === void 0 ? void 0 : model.description) || '',
1627
+ parent_id,
1628
+ project_id,
1629
+ sort: (model === null || model === void 0 ? void 0 : model.sort) || 0,
1630
+ schema: {
1631
+ type: 'object',
1632
+ properties: {},
1633
+ },
1634
+ name: '新建数据模型',
1635
+ display_name: '',
1636
+ created_at: 0,
1637
+ updated_at: 0,
1638
+ // created_id: '',
1639
+ // updated_id: '',
1640
+ version: 0,
1641
+ is_changed: -1,
1642
+ status: 1,
1643
+ created_user_info: {
1644
+ nick_name: '',
1645
+ portrait: '',
1646
+ },
1647
+ updated_user_info: {
1648
+ nick_name: '',
1649
+ portrait: '',
1650
+ },
1651
+ };
1652
+ if (model_type == 'folder') {
1653
+ target['name'] = (model === null || model === void 0 ? void 0 : model.name) || '新建目录';
1654
+ res.models.push(target);
1655
+ ModelItemInit(res, model === null || model === void 0 ? void 0 : model.children, target.model_id, project_id);
1656
+ }
1657
+ else if (model_type == 'model') {
1658
+ target['name'] = (model === null || model === void 0 ? void 0 : model.name) || '新建接口';
1659
+ target['display_name'] = (model === null || model === void 0 ? void 0 : model.displayName) || '';
1660
+ target['schema'] = (model === null || model === void 0 ? void 0 : model.schema) || {};
1661
+ res.models.push(target);
1662
+ }
1663
+ });
1664
+ }
1665
+ };
1666
+ const completionSwaggerApis = (res, apis, project_id) => {
1667
+ var _a;
1668
+ res['apis'] = [];
1669
+ ApiItemInit(res, apis, (_a = res === null || res === void 0 ? void 0 : res.config) === null || _a === void 0 ? void 0 : _a.folder, project_id);
1670
+ };
1671
+ const completionSwaggerModel = (res, dataModel, version, project_id) => {
1672
+ var _a, _b;
1673
+ res['models'] = [];
1674
+ // 新增目录schemas
1675
+ const DEFAULT_FOLDER = {
1676
+ description: '',
1677
+ displayName: '',
1678
+ model_type: 'folder',
1679
+ name: 'schemas',
1680
+ children: dataModel,
1681
+ };
1682
+ if (version === '2.0') {
1683
+ ModelItemInit(res, [DEFAULT_FOLDER], (_a = res === null || res === void 0 ? void 0 : res.config) === null || _a === void 0 ? void 0 : _a.folder, project_id);
1684
+ }
1685
+ else {
1686
+ ModelItemInit(res, dataModel, (_b = res === null || res === void 0 ? void 0 : res.config) === null || _b === void 0 ? void 0 : _b.folder, project_id);
1687
+ }
1688
+ if (res.models.length > 0) {
1689
+ try {
1690
+ const idMap = new Map();
1691
+ res.models.forEach((model) => {
1692
+ if (model.old_model_id) {
1693
+ idMap.set(model.old_model_id, model.model_id);
1694
+ }
1695
+ });
1696
+ const replaceIdsIteratively = (root) => {
1697
+ const stack = [root];
1698
+ const visited = new WeakSet(); // 防止循环引用
1699
+ while (stack.length > 0) {
1700
+ const current = stack.pop();
1701
+ // 跳过基本类型和已访问过的对象
1702
+ if (typeof current !== 'object' || current === null || visited.has(current)) {
1703
+ continue;
1704
+ }
1705
+ visited.add(current);
1706
+ // 处理数组
1707
+ if (Array.isArray(current)) {
1708
+ stack.push(...current);
1709
+ continue;
1710
+ }
1711
+ // 处理对象
1712
+ for (const key in current) {
1713
+ const value = current[key];
1714
+ // 1. 处理普通字符串ID的直接替换(包括完整路径)
1715
+ if (typeof value === 'string' && idMap.has(value)) {
1716
+ current[key] = idMap.get(value);
1717
+ }
1718
+ // 2. 处理嵌套对象
1719
+ else if (typeof value === 'object' && value !== null) {
1720
+ stack.push(value);
1721
+ }
1722
+ }
1723
+ }
1724
+ };
1725
+ replaceIdsIteratively(res.models);
1726
+ replaceIdsIteratively(res.apis);
1727
+ // let dataModelStr = JSON.stringify(res.models);
1728
+ // let apisStr = JSON.stringify(res.apis);
1729
+ // for (const model of res.models) {
1730
+ // if (model?.old_model_id) {
1731
+ // const reg = new RegExp(`"${escapeRegExp(model.old_model_id)}"`, 'g');
1732
+ // dataModelStr = dataModelStr.replace(reg, `"${model.model_id}"`);
1733
+ // apisStr = apisStr.replace(reg, `"${model.model_id}"`);
1734
+ // }
1735
+ // }
1736
+ // res.apis = JSON.parse(apisStr);
1737
+ // res.models = JSON.parse(dataModelStr);
1738
+ }
1739
+ catch (error) { }
1740
+ }
1741
+ };
1468
1742
 
1469
1743
  var securityConnectionMessageNoPath$4 = "When connecting via a secure connection, {{enable}} server certificate validation, and use client version {{version}} with no specified handshake path.";
1470
1744
  var notNeedEnable$4 = "do not enable";
@@ -2300,6 +2574,9 @@ const createPathItem = (item, sourceObj, pid, pidName, modelsObj, apiVersion, ta
2300
2574
  description: (item === null || item === void 0 ? void 0 : item.description) || "",
2301
2575
  tags: []
2302
2576
  };
2577
+ if (lodash.has(item, 'mock_server_enable')) {
2578
+ pathItem['x-mock-server-enable'] = item === null || item === void 0 ? void 0 : item.mock_server_enable;
2579
+ }
2303
2580
  if (lodash.isArray(item === null || item === void 0 ? void 0 : item.tags) && (item === null || item === void 0 ? void 0 : item.tags.length) > 0) {
2304
2581
  pathItem['x-tags'] = item === null || item === void 0 ? void 0 : item.tags;
2305
2582
  }
@@ -2532,6 +2809,7 @@ class ApipostToSwagger {
2532
2809
  const servers = {
2533
2810
  url: (env === null || env === void 0 ? void 0 : env.url) || "",
2534
2811
  description: (env === null || env === void 0 ? void 0 : env.name) || t('createEnv'),
2812
+ "x-env-id": (env === null || env === void 0 ? void 0 : env.env_id) || ''
2535
2813
  };
2536
2814
  if (lodash.isPlainObject(env === null || env === void 0 ? void 0 : env.env_var_list)) {
2537
2815
  servers.variables = {};
@@ -3030,7 +3308,7 @@ class SwaggerToApipost {
3030
3308
  mark_id: (swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.deprecated) ? "4" : "1",
3031
3309
  };
3032
3310
  if (protocol === 'http' || protocol === 'sse') {
3033
- 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) || {})) });
3311
+ 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.responses) || {})) });
3034
3312
  // 根据query参数 重新生成url
3035
3313
  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) || []);
3036
3314
  }
@@ -3045,10 +3323,10 @@ class SwaggerToApipost {
3045
3323
  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) || []);
3046
3324
  }
3047
3325
  if (protocol === 'graphql') {
3048
- baseApiInfo = Object.assign(Object.assign({}, baseApiInfo), { url, request: completionGraphqlRequest(swaggerApi), response: completionResponse((swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.response) || {}) });
3326
+ baseApiInfo = Object.assign(Object.assign({}, baseApiInfo), { url, request: completionGraphqlRequest(swaggerApi), response: completionResponse((swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.responses) || {}) });
3049
3327
  }
3050
3328
  if (protocol === 'socket_method') {
3051
- 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) || {})) });
3329
+ baseApiInfo = Object.assign(Object.assign({}, baseApiInfo), { method: 'TCP', url, request: completionSocketMethodRequest(swaggerApi), response: Object.assign({}, completionResponse((swaggerApi === null || swaggerApi === void 0 ? void 0 : swaggerApi.responses) || {})) });
3052
3330
  }
3053
3331
  if (protocol === 'doc') {
3054
3332
  baseApiInfo = Object.assign({}, baseApiInfo);
@@ -8327,6 +8605,20 @@ class ThunderToApipost {
8327
8605
  }
8328
8606
  }
8329
8607
 
8608
+ const swaggerConverFormat = (json, baseConfig, project_id) => {
8609
+ const { project, env, apis, config, dataModel, version } = json || {};
8610
+ const res = {
8611
+ global: {},
8612
+ };
8613
+ // 不要动顺序ß
8614
+ completionConfig(res, config, baseConfig);
8615
+ completionProject(res, project, project_id);
8616
+ completionSwaggerEnv(res, env);
8617
+ completionSwaggerApis(res, apis, project_id);
8618
+ completionSwaggerModel(res, dataModel, version, project_id);
8619
+ return res;
8620
+ };
8621
+
8330
8622
  exports.ApiToSwagger = ApipostToSwagger;
8331
8623
  exports.ApidocToApipost = ApidocToApipost;
8332
8624
  exports.ApifoxToApipost = ApifoxToApipost;
@@ -8334,6 +8626,7 @@ exports.ApipostToPostman = ApipostToPostman;
8334
8626
  exports.HarToApipost = HarToApipost;
8335
8627
  exports.InsomniaToApipost = InsomniaToApipost;
8336
8628
  exports.PostmanToApipost = PostmanToApipost;
8629
+ exports.SwaggerConverFormat = swaggerConverFormat;
8337
8630
  exports.SwaggerToApipost = SwaggerToApipost;
8338
8631
  exports.ThunderToApipost = ThunderToApipost;
8339
8632
  exports.YapiToApipost = YapiToApipost;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoapi-converter",
3
- "version": "0.0.83",
3
+ "version": "0.0.84",
4
4
  "description": "echoapi to swagger",
5
5
  "main": "dist/index.js",
6
6
  "files": [
package/dist/test.js DELETED
@@ -1,5 +0,0 @@
1
- import { SwaggerToApipost } from './index';
2
-
3
- const aa = new SwaggerToApipost();
4
- const data= aa.convert({});
5
- console.log(data,"111")