@wx-sab/renkei 1.2.0 → 1.2.2
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/lib/core/generate.js +10 -1
- package/lib/core/interface.d.ts +1 -1
- package/package.json +1 -1
- package/templates/api.ejs +2 -2
package/lib/core/generate.js
CHANGED
|
@@ -68,7 +68,7 @@ const generate = (conf) => {
|
|
|
68
68
|
onCreateRouteName(routeNameInfo, rawRouteInfo) {
|
|
69
69
|
var _a, _b, _c;
|
|
70
70
|
// 自定义请求路由
|
|
71
|
-
const newRoute = (_a = config.customRequestUrl) === null || _a === void 0 ? void 0 : _a.call(config, rawRouteInfo);
|
|
71
|
+
const newRoute = (_a = config.customRequestUrl) === null || _a === void 0 ? void 0 : _a.call(config, rawRouteInfo, config);
|
|
72
72
|
if (typeof newRoute === "string") {
|
|
73
73
|
rawRouteInfo.route = newRoute;
|
|
74
74
|
}
|
|
@@ -77,6 +77,14 @@ const generate = (conf) => {
|
|
|
77
77
|
// @ts-ignore
|
|
78
78
|
rawRouteInfo.mockUrl = newRoute.mockUrl;
|
|
79
79
|
}
|
|
80
|
+
// 检测路径中的常见错误
|
|
81
|
+
if (/ /.test(rawRouteInfo.route)) {
|
|
82
|
+
throw Error(`语法错误,路径中存在空格,请核对,可以尝试通过配置 customRequestUrl 进行处理,当前处理节点为:${rawRouteInfo.route}`);
|
|
83
|
+
}
|
|
84
|
+
else if (/([\u4e00-\u9fa5])/.test(rawRouteInfo.route)) {
|
|
85
|
+
// 如果路径里面包含中文,警告用户,因为通常不会写带中文的api,但是直接抄配置文件很有可能由于大小项目的apifox目录组织结构不同,导致这个问题。
|
|
86
|
+
console.warn(`警告:检测到请求路径中存在中文,这通常是因为错误配置了 customRequestUrl,请进行核对,当前处理路径为:${rawRouteInfo.route} `);
|
|
87
|
+
}
|
|
80
88
|
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);
|
|
81
89
|
const duplicate = methodNameSet.has(methodName);
|
|
82
90
|
methodNameSet.add(methodName);
|
|
@@ -153,6 +161,7 @@ const generateApis = (config, services // 指定服务
|
|
|
153
161
|
yield (0, exports.generate)(conf);
|
|
154
162
|
}
|
|
155
163
|
catch (e) {
|
|
164
|
+
console.error(e.message);
|
|
156
165
|
failedServices.push(conf.serviceName);
|
|
157
166
|
}
|
|
158
167
|
finally {
|
package/lib/core/interface.d.ts
CHANGED
package/package.json
CHANGED
package/templates/api.ejs
CHANGED
|
@@ -37,7 +37,7 @@ const descriptionLines = _.compact([
|
|
|
37
37
|
*/
|
|
38
38
|
<% } %>
|
|
39
39
|
|
|
40
|
-
import { AxiosResponse, AxiosRequestConfig } from 'axios'
|
|
40
|
+
import type { AxiosResponse, AxiosRequestConfig } from 'axios'
|
|
41
41
|
import type { <%~ modelNamespace %> } from './model.d.ts'
|
|
42
42
|
|
|
43
43
|
// 自定义 request 模板
|
|
@@ -99,4 +99,4 @@ export class <%~ serviceName %> {
|
|
|
99
99
|
<% }) %>
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
export { <%~ modelNamespace %> }
|
|
102
|
+
export { <%~ modelNamespace %> }
|