@wx-sab/renkei 0.2.7 → 0.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -12,6 +12,8 @@
12
12
  - [x] 支持远程 `apifox` 远程 Mock
13
13
  - [x] 多服务的 apifox 项目解析
14
14
  - [x] 支持 swagger 3.0 解析
15
+ - [x] 支持自定义生成接口名
16
+ - [ ] 支持过滤部分接口
15
17
 
16
18
  ## Introduce
17
19
 
@@ -63,7 +63,7 @@ const generate = (conf) => {
63
63
  ],
64
64
  hooks: {
65
65
  onCreateRouteName(routeNameInfo, rawRouteInfo) {
66
- var _a;
66
+ var _a, _b, _c;
67
67
  // 自定义请求路由
68
68
  const newRoute = (_a = config.customRequestUrl) === null || _a === void 0 ? void 0 : _a.call(config, rawRouteInfo);
69
69
  if (typeof newRoute === "string") {
@@ -74,7 +74,7 @@ const generate = (conf) => {
74
74
  // @ts-ignore
75
75
  rawRouteInfo.mockUrl = newRoute.mockUrl;
76
76
  }
77
- const methodName = (0, utils_1.generateRouteName)(rawRouteInfo.method, rawRouteInfo.route);
77
+ const methodName = (_c = (_b = config === null || config === void 0 ? void 0 : config.customRouteName) === null || _b === void 0 ? void 0 : _b.call(config, routeNameInfo, rawRouteInfo)) !== null && _c !== void 0 ? _c : (0, utils_1.generateRouteName)(rawRouteInfo.method, rawRouteInfo.route);
78
78
  const duplicate = methodNameSet.has(methodName);
79
79
  methodNameSet.add(methodName);
80
80
  return {
@@ -122,7 +122,7 @@ const generateApis = (config) => __awaiter(void 0, void 0, void 0, function* ()
122
122
  conf.forEach((con) => collectConfig(con, collects));
123
123
  }
124
124
  else if (Array.isArray(conf.projects)) {
125
- conf.projects.forEach((project) => collectConfig(Object.assign(Object.assign({}, conf), project), collects));
125
+ conf.projects.forEach((project) => collectConfig(Object.assign(Object.assign({}, lodash_1.default.omit(conf, 'projects')), project), collects));
126
126
  }
127
127
  else {
128
128
  collects.push(conf);
@@ -1,4 +1,4 @@
1
- import { GenerateApiParams, RawRouteInfo } from "swagger-typescript-api";
1
+ import { GenerateApiParams, RawRouteInfo, RouteNameInfo } from "swagger-typescript-api";
2
2
  /**
3
3
  * 基础配置
4
4
  */
@@ -56,6 +56,10 @@ export type BasicConfig = {
56
56
  */
57
57
  mockUrl?: string;
58
58
  };
59
+ /**
60
+ * 自定义生成的接口名
61
+ */
62
+ customRouteName?(routeNameInfo: RouteNameInfo, rawRouteInfo: RawRouteInfo): string;
59
63
  };
60
64
  /**
61
65
  * 如果 sourceType 是 apifox,则适用该配置项
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wx-sab/renkei",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "description": "解析swagger转为ts代码,日本动漫《游戏王》中的‘Renkei’,意为连携或协作。",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {