@midwayjs/swagger 3.5.3 → 3.6.0
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/configuration.js +3 -4
- package/dist/decorators/api-exclude-controller.decorator.js +2 -2
- package/dist/decorators/api-exclude-endpoint.decorator.js +2 -2
- package/dist/decorators/api-header.decorator.js +2 -2
- package/dist/decorators/api-operation.decorator.js +2 -2
- package/dist/decorators/api-response.decorator.js +2 -2
- package/dist/decorators/api-security.decorator.js +2 -2
- package/dist/decorators/helpers.js +4 -4
- package/dist/swaggerExplorer.js +41 -34
- package/dist/swaggerMiddleware.d.ts +1 -1
- package/dist/swaggerMiddleware.js +6 -7
- package/package.json +7 -8
package/dist/configuration.js
CHANGED
|
@@ -11,7 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SwaggerConfiguration = void 0;
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
15
14
|
const _1 = require(".");
|
|
16
15
|
const DefaultConfig = require("./config/config.default");
|
|
17
16
|
let SwaggerConfiguration = class SwaggerConfiguration {
|
|
@@ -37,15 +36,15 @@ let SwaggerConfiguration = class SwaggerConfiguration {
|
|
|
37
36
|
}
|
|
38
37
|
};
|
|
39
38
|
__decorate([
|
|
40
|
-
(0,
|
|
39
|
+
(0, core_1.Inject)(),
|
|
41
40
|
__metadata("design:type", core_1.MidwayApplicationManager)
|
|
42
41
|
], SwaggerConfiguration.prototype, "applicationManager", void 0);
|
|
43
42
|
__decorate([
|
|
44
|
-
(0,
|
|
43
|
+
(0, core_1.Inject)(),
|
|
45
44
|
__metadata("design:type", core_1.MidwayConfigService)
|
|
46
45
|
], SwaggerConfiguration.prototype, "configService", void 0);
|
|
47
46
|
SwaggerConfiguration = __decorate([
|
|
48
|
-
(0,
|
|
47
|
+
(0, core_1.Configuration)({
|
|
49
48
|
importConfigs: [
|
|
50
49
|
{
|
|
51
50
|
default: DefaultConfig,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiExcludeController = void 0;
|
|
4
|
-
const
|
|
4
|
+
const core_1 = require("@midwayjs/core");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
function ApiExcludeController(disable = true) {
|
|
7
|
-
return (0,
|
|
7
|
+
return (0, core_1.createCustomMethodDecorator)(constants_1.DECORATORS.API_EXCLUDE_CONTROLLER, [disable], false);
|
|
8
8
|
}
|
|
9
9
|
exports.ApiExcludeController = ApiExcludeController;
|
|
10
10
|
//# sourceMappingURL=api-exclude-controller.decorator.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiExcludeEndpoint = void 0;
|
|
4
|
-
const
|
|
4
|
+
const core_1 = require("@midwayjs/core");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
function ApiExcludeEndpoint(disable = true) {
|
|
7
|
-
return (0,
|
|
7
|
+
return (0, core_1.createCustomMethodDecorator)(constants_1.DECORATORS.API_EXCLUDE_ENDPOINT, {
|
|
8
8
|
disable,
|
|
9
9
|
}, false);
|
|
10
10
|
}
|
|
@@ -4,7 +4,7 @@ exports.ApiHeaders = exports.ApiHeader = void 0;
|
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const enum_utils_1 = require("../common/enum.utils");
|
|
6
6
|
const helpers_1 = require("./helpers");
|
|
7
|
-
const
|
|
7
|
+
const core_1 = require("@midwayjs/core");
|
|
8
8
|
const defaultHeaderOptions = {
|
|
9
9
|
name: '',
|
|
10
10
|
};
|
|
@@ -30,7 +30,7 @@ function ApiHeader(options) {
|
|
|
30
30
|
if (descriptor) {
|
|
31
31
|
return (0, helpers_1.createParamDecorator)(param, defaultHeaderOptions)(target, key, descriptor);
|
|
32
32
|
}
|
|
33
|
-
return (0,
|
|
33
|
+
return (0, core_1.createCustomMethodDecorator)(constants_1.DECORATORS.API_HEADERS, param, false)(target, undefined, undefined);
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
exports.ApiHeader = ApiHeader;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiOperation = void 0;
|
|
4
|
-
const
|
|
4
|
+
const core_1 = require("@midwayjs/core");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
const defaultOperationOptions = {
|
|
7
7
|
summary: '',
|
|
8
8
|
};
|
|
9
9
|
function ApiOperation(options) {
|
|
10
|
-
return (0,
|
|
10
|
+
return (0, core_1.createCustomMethodDecorator)(constants_1.DECORATORS.API_OPERATION, {
|
|
11
11
|
...defaultOperationOptions,
|
|
12
12
|
...options,
|
|
13
13
|
}, false);
|
|
@@ -4,7 +4,7 @@ exports.ApiDefaultResponse = exports.ApiUnsupportedMediaTypeResponse = exports.A
|
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
5
|
const helpers_1 = require("./helpers");
|
|
6
6
|
const httpStatus_1 = require("../common/httpStatus");
|
|
7
|
-
const
|
|
7
|
+
const core_1 = require("@midwayjs/core");
|
|
8
8
|
function ApiResponse(options) {
|
|
9
9
|
const [type, isArray] = (0, helpers_1.getTypeIsArrayTuple)(options.type, options.isArray);
|
|
10
10
|
options.type = type;
|
|
@@ -13,7 +13,7 @@ function ApiResponse(options) {
|
|
|
13
13
|
const groupedMetadata = {
|
|
14
14
|
[options.status || 'default']: options,
|
|
15
15
|
};
|
|
16
|
-
return (0,
|
|
16
|
+
return (0, core_1.createCustomMethodDecorator)(constants_1.DECORATORS.API_RESPONSE, groupedMetadata, false);
|
|
17
17
|
}
|
|
18
18
|
exports.ApiResponse = ApiResponse;
|
|
19
19
|
const ApiOkResponse = (options = {}) => ApiResponse({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApiSecurity = void 0;
|
|
4
|
-
const
|
|
4
|
+
const core_1 = require("@midwayjs/core");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
function ApiSecurity(name, requirements = []) {
|
|
7
7
|
let metadata;
|
|
@@ -11,7 +11,7 @@ function ApiSecurity(name, requirements = []) {
|
|
|
11
11
|
else {
|
|
12
12
|
metadata = name;
|
|
13
13
|
}
|
|
14
|
-
return (0,
|
|
14
|
+
return (0, core_1.createCustomMethodDecorator)(constants_1.DECORATORS.API_SECURITY, metadata, false);
|
|
15
15
|
}
|
|
16
16
|
exports.ApiSecurity = ApiSecurity;
|
|
17
17
|
//# sourceMappingURL=api-security.decorator.js.map
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSchemaPath = exports.getTypeIsArrayTuple = exports.createParamDecorator = exports.createMixedDecorator = exports.createPropertyDecorator = void 0;
|
|
4
|
-
const
|
|
4
|
+
const core_1 = require("@midwayjs/core");
|
|
5
5
|
const constants_1 = require("../constants");
|
|
6
6
|
function createPropertyDecorator(metakey, metadata) {
|
|
7
|
-
return (0,
|
|
7
|
+
return (0, core_1.createCustomPropertyDecorator)(metakey, metadata, false);
|
|
8
8
|
}
|
|
9
9
|
exports.createPropertyDecorator = createPropertyDecorator;
|
|
10
10
|
function createMixedDecorator(metakey, metadata) {
|
|
11
|
-
return (0,
|
|
11
|
+
return (0, core_1.createCustomMethodDecorator)(metakey, metadata, false);
|
|
12
12
|
}
|
|
13
13
|
exports.createMixedDecorator = createMixedDecorator;
|
|
14
14
|
function createParamDecorator(metadata, initial) {
|
|
15
|
-
return (0,
|
|
15
|
+
return (0, core_1.createCustomMethodDecorator)(constants_1.DECORATORS.API_PARAMETERS, {
|
|
16
16
|
...initial,
|
|
17
17
|
...metadata,
|
|
18
18
|
}, false);
|
package/dist/swaggerExplorer.js
CHANGED
|
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SwaggerExplorer = void 0;
|
|
13
|
-
const
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
14
14
|
const constants_1 = require("./constants");
|
|
15
15
|
const documentBuilder_1 = require("./documentBuilder");
|
|
16
16
|
const _1 = require(".");
|
|
@@ -67,7 +67,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
67
67
|
}
|
|
68
68
|
scanApp() {
|
|
69
69
|
var _a;
|
|
70
|
-
const routes = (0,
|
|
70
|
+
const routes = (0, core_1.listModule)(core_1.CONTROLLER_KEY);
|
|
71
71
|
for (const route of routes) {
|
|
72
72
|
this.generatePath(route);
|
|
73
73
|
}
|
|
@@ -80,13 +80,13 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
80
80
|
}
|
|
81
81
|
generatePath(target) {
|
|
82
82
|
this.parseExtraModel(target);
|
|
83
|
-
const metaForMethods = (0,
|
|
83
|
+
const metaForMethods = (0, core_1.getClassMetadata)(core_1.INJECT_CUSTOM_METHOD, target) || [];
|
|
84
84
|
const exs = metaForMethods.filter(item => item.key === constants_1.DECORATORS.API_EXCLUDE_CONTROLLER);
|
|
85
85
|
if (exs[0]) {
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
const metaForParams = (0,
|
|
89
|
-
const controllerOption = (0,
|
|
88
|
+
const metaForParams = (0, core_1.getClassMetadata)(core_1.INJECT_CUSTOM_PARAM, target) || [];
|
|
89
|
+
const controllerOption = (0, core_1.getClassMetadata)(core_1.CONTROLLER_KEY, target);
|
|
90
90
|
const prefix = controllerOption.prefix;
|
|
91
91
|
const tags = metaForMethods.filter(item => item.key === constants_1.DECORATORS.API_TAGS);
|
|
92
92
|
let strTags = [];
|
|
@@ -118,7 +118,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
118
118
|
}
|
|
119
119
|
// const globalMiddleware = controllerOption.routerOptions.middleware;
|
|
120
120
|
// get router info
|
|
121
|
-
const webRouterInfo = (0,
|
|
121
|
+
const webRouterInfo = (0, core_1.getClassMetadata)(core_1.WEB_ROUTER_KEY, target);
|
|
122
122
|
let header = null;
|
|
123
123
|
const headers = metaForMethods.filter(item => item.key === constants_1.DECORATORS.API_HEADERS);
|
|
124
124
|
if (headers.length > 0) {
|
|
@@ -139,8 +139,8 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
139
139
|
const routerArgs = metaForParams[webRouter.method] || [];
|
|
140
140
|
const bds = routerArgs.filter(item => {
|
|
141
141
|
var _a;
|
|
142
|
-
return item.key ===
|
|
143
|
-
((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.type) ===
|
|
142
|
+
return item.key === core_1.WEB_ROUTER_PARAM_KEY &&
|
|
143
|
+
((_a = item === null || item === void 0 ? void 0 : item.metadata) === null || _a === void 0 ? void 0 : _a.type) === core_1.RouteParamTypes.BODY;
|
|
144
144
|
});
|
|
145
145
|
if (bds.length > 1) {
|
|
146
146
|
// swagger not support more than one @Body
|
|
@@ -187,8 +187,8 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
187
187
|
}
|
|
188
188
|
const parameters = [];
|
|
189
189
|
opts[webRouter.requestMethod] = {
|
|
190
|
-
summary: (_a = operMeta === null || operMeta === void 0 ? void 0 : operMeta.metadata) === null || _a === void 0 ? void 0 : _a.summary,
|
|
191
|
-
description: (_b = operMeta === null || operMeta === void 0 ? void 0 : operMeta.metadata) === null || _b === void 0 ? void 0 : _b.description,
|
|
190
|
+
summary: getNotEmptyValue((_a = operMeta === null || operMeta === void 0 ? void 0 : operMeta.metadata) === null || _a === void 0 ? void 0 : _a.summary, webRouter.summary),
|
|
191
|
+
description: getNotEmptyValue((_b = operMeta === null || operMeta === void 0 ? void 0 : operMeta.metadata) === null || _b === void 0 ? void 0 : _b.description, webRouter.description),
|
|
192
192
|
// operationId: `${webRouter.requestMethod}_${(operMeta?.metadata?.operationId || webRouter.method)}`,
|
|
193
193
|
tags: ((_c = operMeta === null || operMeta === void 0 ? void 0 : operMeta.metadata) === null || _c === void 0 ? void 0 : _c.tags) || [],
|
|
194
194
|
};
|
|
@@ -197,8 +197,8 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
197
197
|
* {"key":"web:router_param","parameterIndex":0,"propertyName":"create","metadata":{"type":1,"propertyData":"createCatDto"}}]
|
|
198
198
|
*/
|
|
199
199
|
// WEB_ROUTER_PARAM_KEY
|
|
200
|
-
const args = routerArgs.filter(item => item.key ===
|
|
201
|
-
const types = (0,
|
|
200
|
+
const args = routerArgs.filter(item => item.key === core_1.WEB_ROUTER_PARAM_KEY);
|
|
201
|
+
const types = (0, core_1.getMethodParamTypes)(target, webRouter.method);
|
|
202
202
|
const params = metaForMethods.filter(item => item.key === constants_1.DECORATORS.API_PARAMETERS &&
|
|
203
203
|
item.propertyName === webRouter.method);
|
|
204
204
|
for (const arg of args) {
|
|
@@ -214,7 +214,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
214
214
|
continue;
|
|
215
215
|
}
|
|
216
216
|
}
|
|
217
|
-
if (
|
|
217
|
+
if (core_1.Types.isClass(currentType)) {
|
|
218
218
|
this.parseClzz(currentType);
|
|
219
219
|
p.schema = {
|
|
220
220
|
$ref: '#/components/schemas/' + currentType.name,
|
|
@@ -227,11 +227,11 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
227
227
|
}
|
|
228
228
|
this.parseFromParamsToP(params[params.length - 1 - arg.parameterIndex], p);
|
|
229
229
|
if (p.in === 'body') {
|
|
230
|
-
if (webRouter.requestMethod ===
|
|
230
|
+
if (webRouter.requestMethod === core_1.RequestMethod.GET) {
|
|
231
231
|
continue;
|
|
232
232
|
}
|
|
233
233
|
// 这里兼容一下 @File()、@Files()、@Fields() 装饰器
|
|
234
|
-
if (((_h = arg.metadata) === null || _h === void 0 ? void 0 : _h.type) ===
|
|
234
|
+
if (((_h = arg.metadata) === null || _h === void 0 ? void 0 : _h.type) === core_1.RouteParamTypes.FILESSTREAM) {
|
|
235
235
|
p.schema = {
|
|
236
236
|
type: 'object',
|
|
237
237
|
properties: {
|
|
@@ -247,7 +247,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
247
247
|
};
|
|
248
248
|
p.contentType = _1.BodyContentType.Multipart;
|
|
249
249
|
}
|
|
250
|
-
if (((_j = arg.metadata) === null || _j === void 0 ? void 0 : _j.type) ===
|
|
250
|
+
if (((_j = arg.metadata) === null || _j === void 0 ? void 0 : _j.type) === core_1.RouteParamTypes.FILESTREAM) {
|
|
251
251
|
p.schema = {
|
|
252
252
|
type: 'object',
|
|
253
253
|
properties: {
|
|
@@ -260,7 +260,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
260
260
|
};
|
|
261
261
|
p.contentType = _1.BodyContentType.Multipart;
|
|
262
262
|
}
|
|
263
|
-
if (((_k = arg.metadata) === null || _k === void 0 ? void 0 : _k.type) ===
|
|
263
|
+
if (((_k = arg.metadata) === null || _k === void 0 ? void 0 : _k.type) === core_1.RouteParamTypes.FIELDS) {
|
|
264
264
|
this.expandSchemaRef(p);
|
|
265
265
|
p.contentType = _1.BodyContentType.Multipart;
|
|
266
266
|
}
|
|
@@ -305,7 +305,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
305
305
|
// 这里是引用,赋值可以直接更改
|
|
306
306
|
const tt = resp[k];
|
|
307
307
|
if (tt.type) {
|
|
308
|
-
if (
|
|
308
|
+
if (core_1.Types.isClass(tt.type)) {
|
|
309
309
|
this.parseClzz(tt.type);
|
|
310
310
|
if (tt.isArray) {
|
|
311
311
|
tt.content = {
|
|
@@ -425,7 +425,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
425
425
|
}
|
|
426
426
|
else {
|
|
427
427
|
if (param.type) {
|
|
428
|
-
if (
|
|
428
|
+
if (core_1.Types.isClass(param.type)) {
|
|
429
429
|
this.parseClzz(param.type);
|
|
430
430
|
p.schema = {
|
|
431
431
|
$ref: '#/components/schemas/' + param.type.name,
|
|
@@ -470,7 +470,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
470
470
|
* @param clzz
|
|
471
471
|
*/
|
|
472
472
|
parseExtraModel(clzz) {
|
|
473
|
-
const metaForMethods = (0,
|
|
473
|
+
const metaForMethods = (0, core_1.getClassMetadata)(core_1.INJECT_CUSTOM_METHOD, clzz) || [];
|
|
474
474
|
const extraModels = metaForMethods.filter(item => item.key === constants_1.DECORATORS.API_EXTRA_MODEL);
|
|
475
475
|
for (const m of extraModels) {
|
|
476
476
|
if (Array.isArray(m.metadata)) {
|
|
@@ -492,7 +492,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
492
492
|
return;
|
|
493
493
|
}
|
|
494
494
|
this.parseExtraModel(clzz);
|
|
495
|
-
const props = (0,
|
|
495
|
+
const props = (0, core_1.getClassExtendedMetadata)(core_1.INJECT_CUSTOM_PROPERTY, clzz);
|
|
496
496
|
const tt = {
|
|
497
497
|
type: 'object',
|
|
498
498
|
properties: {},
|
|
@@ -540,7 +540,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
540
540
|
currentType = (_b = metadata === null || metadata === void 0 ? void 0 : metadata.items) === null || _b === void 0 ? void 0 : _b.type;
|
|
541
541
|
metadata === null || metadata === void 0 ? true : delete metadata.items.type;
|
|
542
542
|
}
|
|
543
|
-
if (
|
|
543
|
+
if (core_1.Types.isClass(currentType)) {
|
|
544
544
|
this.parseClzz(currentType);
|
|
545
545
|
if (isArray) {
|
|
546
546
|
tt.properties[key] = {
|
|
@@ -578,7 +578,7 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
578
578
|
}
|
|
579
579
|
else {
|
|
580
580
|
tt.properties[key] = {
|
|
581
|
-
type: (0,
|
|
581
|
+
type: (0, core_1.getPropertyType)(clzz.prototype, key).name,
|
|
582
582
|
format: metadata === null || metadata === void 0 ? void 0 : metadata.format,
|
|
583
583
|
};
|
|
584
584
|
// Date 类型支持
|
|
@@ -657,18 +657,18 @@ let SwaggerExplorer = class SwaggerExplorer {
|
|
|
657
657
|
}
|
|
658
658
|
};
|
|
659
659
|
__decorate([
|
|
660
|
-
(0,
|
|
660
|
+
(0, core_1.Config)('swagger'),
|
|
661
661
|
__metadata("design:type", Object)
|
|
662
662
|
], SwaggerExplorer.prototype, "swaggerConfig", void 0);
|
|
663
663
|
__decorate([
|
|
664
|
-
(0,
|
|
664
|
+
(0, core_1.Init)(),
|
|
665
665
|
__metadata("design:type", Function),
|
|
666
666
|
__metadata("design:paramtypes", []),
|
|
667
667
|
__metadata("design:returntype", Promise)
|
|
668
668
|
], SwaggerExplorer.prototype, "init", null);
|
|
669
669
|
SwaggerExplorer = __decorate([
|
|
670
|
-
(0,
|
|
671
|
-
(0,
|
|
670
|
+
(0, core_1.Provide)(),
|
|
671
|
+
(0, core_1.Scope)(core_1.ScopeEnum.Singleton)
|
|
672
672
|
], SwaggerExplorer);
|
|
673
673
|
exports.SwaggerExplorer = SwaggerExplorer;
|
|
674
674
|
/**
|
|
@@ -698,16 +698,16 @@ function replaceUrl(url, names) {
|
|
|
698
698
|
}
|
|
699
699
|
function convertTypeToString(type) {
|
|
700
700
|
switch (type) {
|
|
701
|
-
case
|
|
701
|
+
case core_1.RouteParamTypes.HEADERS:
|
|
702
702
|
return 'header';
|
|
703
|
-
case
|
|
703
|
+
case core_1.RouteParamTypes.QUERY:
|
|
704
704
|
return 'query';
|
|
705
|
-
case
|
|
705
|
+
case core_1.RouteParamTypes.PARAM:
|
|
706
706
|
return 'path';
|
|
707
|
-
case
|
|
708
|
-
case
|
|
709
|
-
case
|
|
710
|
-
case
|
|
707
|
+
case core_1.RouteParamTypes.BODY:
|
|
708
|
+
case core_1.RouteParamTypes.FIELDS:
|
|
709
|
+
case core_1.RouteParamTypes.FILESSTREAM:
|
|
710
|
+
case core_1.RouteParamTypes.FILESTREAM:
|
|
711
711
|
return 'body';
|
|
712
712
|
default:
|
|
713
713
|
return 'header';
|
|
@@ -727,4 +727,11 @@ function convertSchemaType(value) {
|
|
|
727
727
|
return value;
|
|
728
728
|
}
|
|
729
729
|
}
|
|
730
|
+
function getNotEmptyValue(...args) {
|
|
731
|
+
for (const arg of args) {
|
|
732
|
+
if (arg) {
|
|
733
|
+
return arg;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
}
|
|
730
737
|
//# sourceMappingURL=swaggerExplorer.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { IMiddleware, IMidwayApplication, IMidwayContext, NextFunction } from '@midwayjs/core';
|
|
2
2
|
export declare class SwaggerMiddleware implements IMiddleware<IMidwayContext, NextFunction, unknown> {
|
|
3
3
|
private swaggerConfig;
|
|
4
4
|
private swaggerUiAssetPath;
|
|
@@ -11,7 +11,6 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.SwaggerMiddleware = void 0;
|
|
13
13
|
const core_1 = require("@midwayjs/core");
|
|
14
|
-
const decorator_1 = require("@midwayjs/decorator");
|
|
15
14
|
const fs_1 = require("fs");
|
|
16
15
|
const path_1 = require("path");
|
|
17
16
|
const swaggerExplorer_1 = require("./swaggerExplorer");
|
|
@@ -23,7 +22,7 @@ let SwaggerMiddleware = class SwaggerMiddleware {
|
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
24
|
resolve(app) {
|
|
26
|
-
if (app.getFrameworkType() ===
|
|
25
|
+
if (app.getFrameworkType() === core_1.MidwayFrameworkType.WEB_EXPRESS) {
|
|
27
26
|
return async (req, res, next) => {
|
|
28
27
|
const pathname = req.path;
|
|
29
28
|
if (!this.swaggerUiAssetPath ||
|
|
@@ -116,22 +115,22 @@ let SwaggerMiddleware = class SwaggerMiddleware {
|
|
|
116
115
|
}
|
|
117
116
|
};
|
|
118
117
|
__decorate([
|
|
119
|
-
(0,
|
|
118
|
+
(0, core_1.Config)('swagger'),
|
|
120
119
|
__metadata("design:type", Object)
|
|
121
120
|
], SwaggerMiddleware.prototype, "swaggerConfig", void 0);
|
|
122
121
|
__decorate([
|
|
123
|
-
(0,
|
|
122
|
+
(0, core_1.Inject)(),
|
|
124
123
|
__metadata("design:type", swaggerExplorer_1.SwaggerExplorer)
|
|
125
124
|
], SwaggerMiddleware.prototype, "swaggerExplorer", void 0);
|
|
126
125
|
__decorate([
|
|
127
|
-
(0,
|
|
126
|
+
(0, core_1.Init)(),
|
|
128
127
|
__metadata("design:type", Function),
|
|
129
128
|
__metadata("design:paramtypes", []),
|
|
130
129
|
__metadata("design:returntype", Promise)
|
|
131
130
|
], SwaggerMiddleware.prototype, "init", null);
|
|
132
131
|
SwaggerMiddleware = __decorate([
|
|
133
|
-
(0,
|
|
134
|
-
(0,
|
|
132
|
+
(0, core_1.Provide)(),
|
|
133
|
+
(0, core_1.Scope)(core_1.ScopeEnum.Singleton)
|
|
135
134
|
], SwaggerMiddleware);
|
|
136
135
|
exports.SwaggerMiddleware = SwaggerMiddleware;
|
|
137
136
|
//# sourceMappingURL=swaggerMiddleware.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@midwayjs/swagger",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"main": "dist/index",
|
|
5
5
|
"typings": "index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -9,12 +9,11 @@
|
|
|
9
9
|
"index.d.ts"
|
|
10
10
|
],
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"@midwayjs/core": "^3.
|
|
13
|
-
"@midwayjs/
|
|
14
|
-
"@midwayjs/
|
|
15
|
-
"@midwayjs/
|
|
16
|
-
"
|
|
17
|
-
"swagger-ui-dist": "4.14.1"
|
|
12
|
+
"@midwayjs/core": "^3.6.0",
|
|
13
|
+
"@midwayjs/koa": "^3.6.0",
|
|
14
|
+
"@midwayjs/mock": "^3.6.0",
|
|
15
|
+
"@midwayjs/validate": "^3.6.0",
|
|
16
|
+
"swagger-ui-dist": "4.14.2"
|
|
18
17
|
},
|
|
19
18
|
"author": "Kurten Chan <chinkurten@gmail.com>",
|
|
20
19
|
"license": "MIT",
|
|
@@ -28,5 +27,5 @@
|
|
|
28
27
|
"type": "git",
|
|
29
28
|
"url": "https://github.com/midwayjs/midway.git"
|
|
30
29
|
},
|
|
31
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "22643b0e8519766bb7c68b975930199fc136336e"
|
|
32
31
|
}
|