@midwayjs/swagger 3.14.9-beta.1 → 3.14.9

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2013 - Now midwayjs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -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
- this.documentBuilder.addTag(t.metadata);
125
+ controllerTags.push(Array.isArray(t.metadata) ? [t.metadata] : 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
- this.documentBuilder.addTag(tag.name, tag.description);
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 提取方法
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/swagger",
3
- "version": "3.14.9-beta.1",
3
+ "version": "3.14.9",
4
4
  "main": "dist/index.js",
5
5
  "typings": "index.d.ts",
6
6
  "files": [
@@ -27,5 +27,6 @@
27
27
  "repository": {
28
28
  "type": "git",
29
29
  "url": "https://github.com/midwayjs/midway.git"
30
- }
30
+ },
31
+ "gitHead": "dae4c9da12af95f6f632c86d4166fd2fa0067ecd"
31
32
  }