@midwayjs/swagger 3.14.9-beta.1 → 3.14.9-beta.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/dist/swaggerExplorer.js +16 -2
- package/package.json +1 -1
package/dist/swaggerExplorer.js
CHANGED
|
@@ -116,12 +116,14 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
116
116
|
// 过滤出标签
|
|
117
117
|
const tags = metaForClass.filter(item => item.key === constants_1.DECORATORS.API_TAGS);
|
|
118
118
|
let strTags = [];
|
|
119
|
+
const controllerTags = [];
|
|
119
120
|
// 如果存在标签,则将其添加到文档构建器中
|
|
120
121
|
if (tags.length > 0) {
|
|
121
122
|
for (const t of tags) {
|
|
122
123
|
// 这里 metadata => string[]
|
|
123
124
|
strTags = strTags.concat(t.metadata);
|
|
124
|
-
|
|
125
|
+
controllerTags.push(t.metadata);
|
|
126
|
+
// this.documentBuilder.addTag(t.metadata);
|
|
125
127
|
}
|
|
126
128
|
}
|
|
127
129
|
else {
|
|
@@ -142,7 +144,8 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
142
144
|
// 如果标签名存在,则将其添加到文档构建器中
|
|
143
145
|
if (tag.name) {
|
|
144
146
|
strTags.push(tag.name);
|
|
145
|
-
|
|
147
|
+
controllerTags.push([tag.name, tag.description]);
|
|
148
|
+
// this.documentBuilder.addTag(tag.name, tag.description);
|
|
146
149
|
}
|
|
147
150
|
}
|
|
148
151
|
// 获取路由信息
|
|
@@ -219,6 +222,17 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
219
222
|
}
|
|
220
223
|
// 将路径添加到文档构建器中
|
|
221
224
|
this.documentBuilder.addPaths(paths);
|
|
225
|
+
// 将控制器标签添加到文档构建器中
|
|
226
|
+
if (Object.keys(paths).length > 0) {
|
|
227
|
+
controllerTags.forEach(tag => {
|
|
228
|
+
if (Array.isArray(tag)) {
|
|
229
|
+
this.documentBuilder.addTag(tag[0], tag[1]);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
this.documentBuilder.addTag(tag);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
222
236
|
}
|
|
223
237
|
/**
|
|
224
238
|
* 构造 router 提取方法
|