@midwayjs/swagger 4.0.0-beta.11 → 4.0.0-beta.13

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.
@@ -38,14 +38,15 @@ let SwaggerExplorer = class SwaggerExplorer {
38
38
  typeof this.swaggerConfig?.externalDocs === 'object') {
39
39
  this.documentBuilder.setExternalDoc(this.swaggerConfig?.externalDocs?.description, this.swaggerConfig?.externalDocs?.url);
40
40
  }
41
- if (this.swaggerConfig?.servers &&
42
- Array.isArray(this.swaggerConfig?.servers)) {
43
- for (const serv of this.swaggerConfig?.servers) {
41
+ const servers = this.swaggerConfig?.servers;
42
+ if (Array.isArray(servers)) {
43
+ for (const serv of servers) {
44
44
  this.documentBuilder.addServer(serv?.url, serv?.description, serv?.variables);
45
45
  }
46
46
  }
47
- if (this.swaggerConfig?.tags && Array.isArray(this.swaggerConfig?.tags)) {
48
- for (const t of this.swaggerConfig?.tags) {
47
+ const tags = this.swaggerConfig?.tags;
48
+ if (Array.isArray(tags)) {
49
+ for (const t of tags) {
49
50
  this.documentBuilder.addTag(t.name, t.description, t.externalDocs);
50
51
  }
51
52
  }
@@ -54,13 +55,14 @@ let SwaggerExplorer = class SwaggerExplorer {
54
55
  this.swaggerConfig.documentOptions.operationIdFactory;
55
56
  }
56
57
  // 设置 auth 类型
57
- if (Array.isArray(this.swaggerConfig?.auth)) {
58
- for (const a of this.swaggerConfig?.auth) {
58
+ const authConfig = this.swaggerConfig?.auth;
59
+ if (Array.isArray(authConfig)) {
60
+ for (const a of authConfig) {
59
61
  this.setAuth(a);
60
62
  }
61
63
  }
62
- else {
63
- this.setAuth(this.swaggerConfig?.auth);
64
+ else if (authConfig) {
65
+ this.setAuth(authConfig);
64
66
  }
65
67
  }
66
68
  addGlobalPrefix(globalPrefix) {
@@ -270,7 +272,7 @@ let SwaggerExplorer = class SwaggerExplorer {
270
272
  description: getNotEmptyValue(operMeta?.metadata?.description, webRouter.description),
271
273
  operationId: operMeta?.metadata?.operationId ||
272
274
  this.getOperationId(target.name, webRouter),
273
- tags: routerTags.length ? routerTags : operMeta?.metadata?.tags ?? [],
275
+ tags: routerTags.length ? routerTags : (operMeta?.metadata?.tags ?? []),
274
276
  };
275
277
  if (operMeta?.metadata?.deprecated != null) {
276
278
  opts[webRouter.requestMethod].deprecated =
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/swagger",
3
- "version": "4.0.0-beta.11",
3
+ "version": "4.0.0-beta.13",
4
4
  "description": "Midway Component for Swagger API Documentation",
5
5
  "main": "dist/index.js",
6
6
  "typings": "index.d.ts",
@@ -12,10 +12,10 @@
12
12
  ],
13
13
  "devDependencies": {
14
14
  "@apidevtools/swagger-parser": "11.0.1",
15
- "@midwayjs/core": "^4.0.0-beta.11",
16
- "@midwayjs/koa": "^4.0.0-beta.11",
17
- "@midwayjs/mock": "^4.0.0-beta.11",
18
- "@midwayjs/validate": "^4.0.0-beta.11",
15
+ "@midwayjs/core": "^4.0.0-beta.13",
16
+ "@midwayjs/koa": "^4.0.0-beta.13",
17
+ "@midwayjs/mock": "^4.0.0-beta.13",
18
+ "@midwayjs/validate": "^4.0.0-beta.13",
19
19
  "swagger-ui-dist": "5.18.3"
20
20
  },
21
21
  "author": "Kurten Chan <chinkurten@gmail.com>",
@@ -30,5 +30,5 @@
30
30
  "type": "git",
31
31
  "url": "https://github.com/midwayjs/midway.git"
32
32
  },
33
- "gitHead": "6ef05719ca6e900f1ec34aff7a5c5a9614358c50"
33
+ "gitHead": "9a38b66a84a6880370cac90d737f94f9c5f2f256"
34
34
  }