@midwayjs/swagger 3.4.0-beta.1 → 3.4.0-beta.12

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.
@@ -336,5 +336,24 @@ export interface SwaggerOptions {
336
336
  * 可以使用 1-xxx、2-xxx、3-xxx 来定义 tag
337
337
  */
338
338
  tagSortable?: boolean;
339
+ /**
340
+ * UI 展示中需要用到的配置
341
+ * 可以参考 https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#display
342
+ */
343
+ displayOptions?: {
344
+ deepLinking?: boolean;
345
+ displayOperationId?: boolean;
346
+ defaultModelsExpandDepth?: number;
347
+ defaultModelExpandDepth?: number;
348
+ defaultModelRendering?: 'example' | 'model';
349
+ displayRequestDuration?: boolean;
350
+ docExpansion?: 'list' | 'full' | 'none';
351
+ filter?: boolean | string;
352
+ maxDisplayedTags?: number;
353
+ showExtensions?: boolean;
354
+ showCommonExtensions?: boolean;
355
+ useUnsafeMarkdown?: boolean;
356
+ tryItOutEnabled?: boolean;
357
+ };
339
358
  }
340
359
  //# sourceMappingURL=index.d.ts.map
@@ -381,7 +381,7 @@ let SwaggerExplorer = class SwaggerExplorer {
381
381
  * @param p
382
382
  */
383
383
  parseFromParamsToP(paramMeta, p) {
384
- var _a, _b, _c, _d;
384
+ var _a, _b, _c;
385
385
  if (paramMeta) {
386
386
  const param = paramMeta.metadata;
387
387
  if (param) {
@@ -392,7 +392,7 @@ let SwaggerExplorer = class SwaggerExplorer {
392
392
  if (param.in === 'query') {
393
393
  p.allowEmptyValue = param.allowEmptyValue || false;
394
394
  }
395
- if (param.example) {
395
+ if (typeof param.example !== undefined) {
396
396
  p.example = param.example;
397
397
  }
398
398
  if (param.examples) {
@@ -432,13 +432,22 @@ let SwaggerExplorer = class SwaggerExplorer {
432
432
  };
433
433
  }
434
434
  if (param.isArray) {
435
+ let ref;
436
+ if ((_c = p === null || p === void 0 ? void 0 : p.schema) === null || _c === void 0 ? void 0 : _c.$ref) {
437
+ ref = p.schema.$ref;
438
+ }
435
439
  p.schema = {
436
440
  type: 'array',
437
441
  items: {
438
- type: (_d = (_c = p === null || p === void 0 ? void 0 : p.schema) === null || _c === void 0 ? void 0 : _c.$ref) !== null && _d !== void 0 ? _d : convertSchemaType(param.type),
439
442
  format: param.format,
440
443
  },
441
444
  };
445
+ if (ref) {
446
+ p.schema.items.$ref = ref;
447
+ }
448
+ else {
449
+ p.schema.items.type = convertSchemaType(param.type);
450
+ }
442
451
  }
443
452
  else {
444
453
  if (!p.schema) {
@@ -492,7 +501,7 @@ let SwaggerExplorer = class SwaggerExplorer {
492
501
  Object.keys(props).forEach(key => {
493
502
  var _a, _b;
494
503
  const metadata = props[key].metadata;
495
- if (metadata === null || metadata === void 0 ? void 0 : metadata.example) {
504
+ if (typeof (metadata === null || metadata === void 0 ? void 0 : metadata.example) !== undefined) {
496
505
  if (!tt.example) {
497
506
  tt.example = {};
498
507
  }
@@ -103,7 +103,13 @@ let SwaggerMiddleware = class SwaggerMiddleware {
103
103
  }
104
104
  }
105
105
  replaceInfo(content) {
106
- return content.replace('"https://petstore.swagger.io/v2/swagger.json",', `location.href.replace('${this.swaggerConfig.swaggerPath}/index.html', '${this.swaggerConfig.swaggerPath}/index.json'),\n validatorUrl: null,`);
106
+ let str = `location.href.replace('${this.swaggerConfig.swaggerPath}/index.html', '${this.swaggerConfig.swaggerPath}/index.json'),\n validatorUrl: null,`;
107
+ if (this.swaggerConfig.displayOptions) {
108
+ Object.keys(this.swaggerConfig.displayOptions).forEach(key => {
109
+ str += `\n${key}: ${this.swaggerConfig.displayOptions[key]},`;
110
+ });
111
+ }
112
+ return content.replace('"https://petstore.swagger.io/v2/swagger.json",', str);
107
113
  }
108
114
  static getName() {
109
115
  return 'swagger';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/swagger",
3
- "version": "3.4.0-beta.1",
3
+ "version": "3.4.0-beta.12",
4
4
  "main": "dist/index",
5
5
  "typings": "index.d.ts",
6
6
  "files": [
@@ -9,12 +9,12 @@
9
9
  "index.d.ts"
10
10
  ],
11
11
  "devDependencies": {
12
- "@midwayjs/core": "^3.4.0-beta.1",
13
- "@midwayjs/decorator": "^3.4.0-beta.1",
14
- "@midwayjs/koa": "^3.4.0-beta.1",
15
- "@midwayjs/mock": "^3.4.0-beta.1",
16
- "@midwayjs/validate": "^3.4.0-beta.1",
17
- "swagger-ui-dist": "4.6.2"
12
+ "@midwayjs/core": "^3.4.0-beta.12",
13
+ "@midwayjs/decorator": "^3.4.0-beta.12",
14
+ "@midwayjs/koa": "^3.4.0-beta.12",
15
+ "@midwayjs/mock": "^3.4.0-beta.12",
16
+ "@midwayjs/validate": "^3.4.0-beta.12",
17
+ "swagger-ui-dist": "4.12.0"
18
18
  },
19
19
  "author": "Kurten Chan <chinkurten@gmail.com>",
20
20
  "license": "MIT",
@@ -27,5 +27,6 @@
27
27
  "repository": {
28
28
  "type": "git",
29
29
  "url": "https://github.com/midwayjs/midway.git"
30
- }
30
+ },
31
+ "gitHead": "cb639763ececfc7928221eaafbd515bfd93c6ca1"
31
32
  }
package/CHANGELOG.md DELETED
@@ -1,370 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [3.3.14](https://github.com/midwayjs/midway/compare/v3.3.13...v3.3.14) (2022-06-17)
7
-
8
-
9
- ### Bug Fixes
10
-
11
- * swagger delete example when extends ([#2041](https://github.com/midwayjs/midway/issues/2041)) ([47b62b8](https://github.com/midwayjs/midway/commit/47b62b8ebfb4a5ad4fe9ca0ba0038bb324711404))
12
-
13
-
14
-
15
-
16
-
17
- ## [3.3.13](https://github.com/midwayjs/midway/compare/v3.3.12...v3.3.13) (2022-06-06)
18
-
19
-
20
- ### Bug Fixes
21
-
22
- * swagger items assign bug ([#2025](https://github.com/midwayjs/midway/issues/2025)) ([e81a79f](https://github.com/midwayjs/midway/commit/e81a79fd9f88af56d5e1da7421548388d118b2ec))
23
-
24
-
25
-
26
-
27
-
28
- ## [3.3.8](https://github.com/midwayjs/midway/compare/v3.3.7...v3.3.8) (2022-05-17)
29
-
30
-
31
- ### Bug Fixes
32
-
33
- * compatible date type ([#1979](https://github.com/midwayjs/midway/issues/1979)) ([24140f1](https://github.com/midwayjs/midway/commit/24140f1c2b93e8c3a10b996e0f135b260abfbf86))
34
-
35
-
36
-
37
-
38
-
39
- ## [3.3.6](https://github.com/midwayjs/midway/compare/v3.3.5...v3.3.6) (2022-05-11)
40
-
41
- **Note:** Version bump only for package @midwayjs/swagger
42
-
43
-
44
-
45
-
46
-
47
- ## [3.3.5](https://github.com/midwayjs/midway/compare/v3.3.4...v3.3.5) (2022-04-27)
48
-
49
- **Note:** Version bump only for package @midwayjs/swagger
50
-
51
-
52
-
53
-
54
-
55
- ## [3.3.4](https://github.com/midwayjs/midway/compare/v3.3.3...v3.3.4) (2022-04-21)
56
-
57
- **Note:** Version bump only for package @midwayjs/swagger
58
-
59
-
60
-
61
-
62
-
63
- ## [3.3.2](https://github.com/midwayjs/midway/compare/v3.3.1...v3.3.2) (2022-04-13)
64
-
65
- **Note:** Version bump only for package @midwayjs/swagger
66
-
67
-
68
-
69
-
70
-
71
- ## [3.3.1](https://github.com/midwayjs/midway/compare/v3.3.0...v3.3.1) (2022-04-11)
72
-
73
-
74
- ### Bug Fixes
75
-
76
- * swagger_extend_bug ([#1894](https://github.com/midwayjs/midway/issues/1894)) ([b918ef8](https://github.com/midwayjs/midway/commit/b918ef871f6daf43a1bf3754e705b7c3e12bf3cd))
77
-
78
-
79
-
80
-
81
-
82
- # [3.3.0](https://github.com/midwayjs/midway/compare/v3.2.2...v3.3.0) (2022-04-07)
83
-
84
-
85
- ### Features
86
-
87
- * add ApiExtraModel && fix items bug ([#1873](https://github.com/midwayjs/midway/issues/1873)) ([40cce3b](https://github.com/midwayjs/midway/commit/40cce3be1d8ebd5b2723aff2e6d6d488024c5a56))
88
-
89
-
90
-
91
-
92
-
93
- ## [3.2.2](https://github.com/midwayjs/midway/compare/v3.2.1...v3.2.2) (2022-03-30)
94
-
95
- **Note:** Version bump only for package @midwayjs/swagger
96
-
97
-
98
-
99
-
100
-
101
- ## [3.2.1](https://github.com/midwayjs/midway/compare/v3.2.0...v3.2.1) (2022-03-27)
102
-
103
-
104
- ### Bug Fixes
105
-
106
- * swagger ui replace json path ([#1860](https://github.com/midwayjs/midway/issues/1860)) ([0f3728d](https://github.com/midwayjs/midway/commit/0f3728daccba12923f23f5b498c7dda13ced36d7))
107
-
108
-
109
-
110
-
111
-
112
- # [3.2.0](https://github.com/midwayjs/midway/compare/v3.1.6...v3.2.0) (2022-03-25)
113
-
114
-
115
- ### Bug Fixes
116
-
117
- * swagger getSchemaPath bug ([#1850](https://github.com/midwayjs/midway/issues/1850)) ([e3adda0](https://github.com/midwayjs/midway/commit/e3adda0e4f5c470d44d66b11e2e5b39a7ecc6bea))
118
-
119
-
120
-
121
-
122
-
123
- ## [3.1.6](https://github.com/midwayjs/midway/compare/v3.1.5...v3.1.6) (2022-03-21)
124
-
125
- **Note:** Version bump only for package @midwayjs/swagger
126
-
127
-
128
-
129
-
130
-
131
- ## [3.1.5](https://github.com/midwayjs/midway/compare/v3.1.4...v3.1.5) (2022-03-18)
132
-
133
- **Note:** Version bump only for package @midwayjs/swagger
134
-
135
-
136
-
137
-
138
-
139
- ## [3.1.2](https://github.com/midwayjs/midway/compare/v3.1.1...v3.1.2) (2022-03-15)
140
-
141
-
142
- ### Bug Fixes
143
-
144
- * remove swagger validator url ([#1813](https://github.com/midwayjs/midway/issues/1813)) ([ded291a](https://github.com/midwayjs/midway/commit/ded291a308f81961f9f3c2a9c21b5862d7d73ca6))
145
-
146
-
147
-
148
-
149
-
150
- ## [3.1.1](https://github.com/midwayjs/midway/compare/v3.1.0...v3.1.1) (2022-03-09)
151
-
152
- **Note:** Version bump only for package @midwayjs/swagger
153
-
154
-
155
-
156
-
157
-
158
- # [3.1.0](https://github.com/midwayjs/midway/compare/v3.0.13...v3.1.0) (2022-03-07)
159
-
160
- **Note:** Version bump only for package @midwayjs/swagger
161
-
162
-
163
-
164
-
165
-
166
- ## [3.0.13](https://github.com/midwayjs/midway/compare/v3.0.12...v3.0.13) (2022-03-01)
167
-
168
- **Note:** Version bump only for package @midwayjs/swagger
169
-
170
-
171
-
172
-
173
-
174
- ## [3.0.11](https://github.com/midwayjs/midway/compare/v3.0.10...v3.0.11) (2022-02-25)
175
-
176
- **Note:** Version bump only for package @midwayjs/swagger
177
-
178
-
179
-
180
-
181
-
182
- ## [3.0.10](https://github.com/midwayjs/midway/compare/v3.0.9...v3.0.10) (2022-02-24)
183
-
184
- **Note:** Version bump only for package @midwayjs/swagger
185
-
186
-
187
-
188
-
189
-
190
- ## [3.0.9](https://github.com/midwayjs/midway/compare/v3.0.8...v3.0.9) (2022-02-21)
191
-
192
- **Note:** Version bump only for package @midwayjs/swagger
193
-
194
-
195
-
196
-
197
-
198
- ## [3.0.8](https://github.com/midwayjs/midway/compare/v3.0.7...v3.0.8) (2022-02-19)
199
-
200
- **Note:** Version bump only for package @midwayjs/swagger
201
-
202
-
203
-
204
-
205
-
206
- ## [3.0.7](https://github.com/midwayjs/midway/compare/v3.0.6...v3.0.7) (2022-02-17)
207
-
208
- **Note:** Version bump only for package @midwayjs/swagger
209
-
210
-
211
-
212
-
213
-
214
- ## [3.0.6](https://github.com/midwayjs/midway/compare/v3.0.5...v3.0.6) (2022-02-13)
215
-
216
- **Note:** Version bump only for package @midwayjs/swagger
217
-
218
-
219
-
220
-
221
-
222
- ## [3.0.5](https://github.com/midwayjs/midway/compare/v3.0.4...v3.0.5) (2022-02-10)
223
-
224
-
225
- ### Bug Fixes
226
-
227
- * swagger query/param bug ([#1682](https://github.com/midwayjs/midway/issues/1682)) ([c05df75](https://github.com/midwayjs/midway/commit/c05df757bc8fd15d893d0dcf7455fc1b6a12d171))
228
-
229
-
230
-
231
-
232
-
233
- ## [3.0.4](https://github.com/midwayjs/midway/compare/v3.0.3...v3.0.4) (2022-02-09)
234
-
235
-
236
- ### Bug Fixes
237
-
238
- * supertest typings and createFunctionApp ([#1642](https://github.com/midwayjs/midway/issues/1642)) ([484f4f4](https://github.com/midwayjs/midway/commit/484f4f41b3b9e889d4d285f4871a0b37fa51e73f))
239
- * swagger not support more than one @Body ([#1662](https://github.com/midwayjs/midway/issues/1662)) ([a13ec48](https://github.com/midwayjs/midway/commit/a13ec48fa4b3f97f013dc73be409631b4ce2e24e))
240
- * swagger support globalprefix ([#1670](https://github.com/midwayjs/midway/issues/1670)) ([75e83f9](https://github.com/midwayjs/midway/commit/75e83f9fbedb7acbcc20ffac15cb4afaf4513957))
241
-
242
-
243
-
244
-
245
-
246
- ## [3.0.3](https://github.com/midwayjs/midway/compare/v3.0.2...v3.0.3) (2022-01-28)
247
-
248
- **Note:** Version bump only for package @midwayjs/swagger
249
-
250
-
251
-
252
-
253
-
254
- ## [3.0.2](https://github.com/midwayjs/midway/compare/v3.0.1...v3.0.2) (2022-01-24)
255
-
256
-
257
- ### Bug Fixes
258
-
259
- * singleton invoke request scope not valid ([#1622](https://github.com/midwayjs/midway/issues/1622)) ([f97c063](https://github.com/midwayjs/midway/commit/f97c0632107b47cf357d17774a4e4bb5233bba57))
260
-
261
-
262
-
263
-
264
-
265
- ## [3.0.1](https://github.com/midwayjs/midway/compare/v3.0.0...v3.0.1) (2022-01-24)
266
-
267
- **Note:** Version bump only for package @midwayjs/swagger
268
-
269
-
270
-
271
-
272
-
273
- # [3.0.0](https://github.com/midwayjs/midway/compare/v3.0.0-beta.17...v3.0.0) (2022-01-20)
274
-
275
- **Note:** Version bump only for package @midwayjs/swagger
276
-
277
-
278
-
279
-
280
-
281
- # [3.0.0-beta.17](https://github.com/midwayjs/midway/compare/v3.0.0-beta.16...v3.0.0-beta.17) (2022-01-18)
282
-
283
-
284
- ### Bug Fixes
285
-
286
- * move koa-session and definition ([#1572](https://github.com/midwayjs/midway/issues/1572)) ([95743c1](https://github.com/midwayjs/midway/commit/95743c11917507ccf4c218f5353e1b88917237a5))
287
-
288
-
289
-
290
-
291
-
292
- # [3.0.0-beta.16](https://github.com/midwayjs/midway/compare/v3.0.0-beta.15...v3.0.0-beta.16) (2022-01-11)
293
-
294
-
295
- ### Bug Fixes
296
-
297
- * @File/@Files schema no type bug ([#1532](https://github.com/midwayjs/midway/issues/1532)) ([a776b3d](https://github.com/midwayjs/midway/commit/a776b3d890ab1faeb3164a42e1dcc953415f8f89))
298
-
299
-
300
- ### Features
301
-
302
- * swagger tags support ascii order ([#1548](https://github.com/midwayjs/midway/issues/1548)) ([f60438f](https://github.com/midwayjs/midway/commit/f60438f4dcf56538de0a1f0978fde8053660ec4c))
303
-
304
-
305
-
306
-
307
-
308
- # [3.0.0-beta.15](https://github.com/midwayjs/midway/compare/v3.0.0-beta.14...v3.0.0-beta.15) (2022-01-07)
309
-
310
-
311
- ### Features
312
-
313
- * compatible with @File/@Files/@Fields ([#1527](https://github.com/midwayjs/midway/issues/1527)) ([3fe983f](https://github.com/midwayjs/midway/commit/3fe983f2a67c366af370c41df98510adf5dab289))
314
-
315
-
316
-
317
-
318
-
319
- # [3.0.0-beta.14](https://github.com/midwayjs/midway/compare/v3.0.0-beta.13...v3.0.0-beta.14) (2022-01-04)
320
-
321
- **Note:** Version bump only for package @midwayjs/swagger
322
-
323
-
324
-
325
-
326
-
327
- # [3.0.0-beta.13](https://github.com/midwayjs/midway/compare/v3.0.0-beta.12...v3.0.0-beta.13) (2021-12-30)
328
-
329
-
330
- ### Features
331
-
332
- * add custom decorator filter ([#1477](https://github.com/midwayjs/midway/issues/1477)) ([97501a9](https://github.com/midwayjs/midway/commit/97501a989abc211b0c7400b1df45e050bb237c6a))
333
-
334
-
335
-
336
-
337
-
338
- # [3.0.0-beta.12](https://github.com/midwayjs/midway/compare/v3.0.0-beta.11...v3.0.0-beta.12) (2021-12-28)
339
-
340
-
341
- ### Bug Fixes
342
-
343
- * 3.x copy all properties ([#1444](https://github.com/midwayjs/midway/issues/1444)) ([21ec8b6](https://github.com/midwayjs/midway/commit/21ec8b6a85b6ba3f4fbff0c8a571484aaa078788))
344
-
345
-
346
- ### Features
347
-
348
- * add fileupload support ([#1439](https://github.com/midwayjs/midway/issues/1439)) ([0a81e72](https://github.com/midwayjs/midway/commit/0a81e720f525ddab0718301f44f80fce376f9bfe))
349
- * support throw err status ([#1440](https://github.com/midwayjs/midway/issues/1440)) ([7b98110](https://github.com/midwayjs/midway/commit/7b98110d65c5287a8fcb3eb5356dea2d7a32cee9))
350
-
351
-
352
-
353
-
354
-
355
- # [3.0.0-beta.11](https://github.com/midwayjs/midway/compare/v3.0.0-beta.10...v3.0.0-beta.11) (2021-12-21)
356
-
357
- **Note:** Version bump only for package @midwayjs/swagger
358
-
359
-
360
-
361
-
362
-
363
- # [3.0.0-beta.10](https://github.com/midwayjs/midway/compare/v3.0.0-beta.9...v3.0.0-beta.10) (2021-12-20)
364
-
365
-
366
- ### Features
367
-
368
- * 3.x swagger ([#1409](https://github.com/midwayjs/midway/issues/1409)) ([e00fbbf](https://github.com/midwayjs/midway/commit/e00fbbf7a494f300a53f3bd8635966364cfd96a9))
369
- * add swagger doc & fix bug ([#1427](https://github.com/midwayjs/midway/issues/1427)) ([82dc6f1](https://github.com/midwayjs/midway/commit/82dc6f10f7244a75f58922edda1b0625fc6cb90e))
370
- * support express ([61e73db](https://github.com/midwayjs/midway/commit/61e73db509bfea21c8251855fccb02a4ce09988f))