@midwayjs/swagger 1.0.7 → 3.0.0-beta.10
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/CHANGELOG.md +4 -95
- package/LICENSE +21 -0
- package/README.md +8 -22
- package/dist/common/enum.utils.d.ts +9 -0
- package/dist/common/enum.utils.js +63 -0
- package/dist/common/httpStatus.d.ts +51 -0
- package/dist/common/httpStatus.js +55 -0
- package/dist/config/config.default.d.ts +2 -8
- package/dist/config/config.default.js +6 -6
- package/dist/configuration.d.ts +4 -2
- package/dist/configuration.js +28 -12
- package/dist/constants.d.ts +15 -0
- package/dist/constants.js +18 -0
- package/dist/decorators/api-basic.decorator.d.ts +2 -0
- package/dist/decorators/api-basic.decorator.js +9 -0
- package/dist/decorators/api-bearer.decorator.d.ts +2 -0
- package/dist/decorators/api-bearer.decorator.js +9 -0
- package/dist/decorators/api-body.decorator.d.ts +16 -0
- package/dist/decorators/api-body.decorator.js +27 -0
- package/dist/decorators/api-cookie.decorator.d.ts +2 -0
- package/dist/decorators/api-cookie.decorator.js +9 -0
- package/dist/decorators/api-exclude-controller.decorator.d.ts +2 -0
- package/dist/decorators/api-exclude-controller.decorator.js +12 -0
- package/dist/decorators/api-exclude-endpoint.decorator.d.ts +2 -0
- package/dist/decorators/api-exclude-endpoint.decorator.js +12 -0
- package/dist/decorators/api-extension.decorator.d.ts +2 -0
- package/dist/decorators/api-extension.decorator.js +16 -0
- package/dist/decorators/api-header.decorator.d.ts +7 -0
- package/dist/decorators/api-header.decorator.js +43 -0
- package/dist/decorators/api-oauth2.decorator.d.ts +2 -0
- package/dist/decorators/api-oauth2.decorator.js +9 -0
- package/dist/decorators/api-operation.decorator.d.ts +4 -0
- package/dist/decorators/api-operation.decorator.js +16 -0
- package/dist/decorators/api-param.decorator.d.ts +15 -0
- package/dist/decorators/api-param.decorator.js +30 -0
- package/dist/decorators/api-property.decorator.d.ts +11 -0
- package/dist/decorators/api-property.decorator.js +56 -0
- package/dist/decorators/api-query.decorator.d.ts +17 -0
- package/dist/decorators/api-query.decorator.js +31 -0
- package/dist/decorators/api-response.decorator.d.ts +41 -0
- package/dist/decorators/api-response.decorator.js +149 -0
- package/dist/decorators/api-security.decorator.d.ts +3 -0
- package/dist/decorators/api-security.decorator.js +17 -0
- package/dist/decorators/api-tags.decorator.d.ts +2 -0
- package/dist/decorators/api-tags.decorator.js +10 -0
- package/dist/decorators/helpers.d.ts +7 -0
- package/dist/decorators/helpers.js +41 -0
- package/dist/decorators/index.d.ts +18 -0
- package/dist/decorators/index.js +35 -0
- package/dist/documentBuilder.d.ts +25 -0
- package/dist/documentBuilder.js +192 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +9 -6
- package/dist/interfaces/index.d.ts +339 -0
- package/dist/interfaces/index.js +7 -0
- package/dist/swaggerExplorer.d.ts +30 -0
- package/dist/swaggerExplorer.js +580 -0
- package/dist/swaggerMiddleware.d.ts +9 -0
- package/dist/swaggerMiddleware.js +123 -0
- package/index.d.ts +8 -0
- package/package.json +15 -15
- package/dist/controller/swagger.d.ts +0 -31
- package/dist/controller/swagger.js +0 -94
- package/dist/interface.d.ts +0 -16
- package/dist/interface.js +0 -3
- package/dist/lib/createAPI.d.ts +0 -51
- package/dist/lib/createAPI.js +0 -276
- package/dist/lib/document.d.ts +0 -117
- package/dist/lib/document.js +0 -131
- package/dist/lib/generator.d.ts +0 -30
- package/dist/lib/generator.js +0 -240
- package/dist/service/generator.d.ts +0 -24
- package/dist/service/generator.js +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -3,102 +3,11 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Bug Fixes
|
|
10
|
-
|
|
11
|
-
* [#26](https://github.com/midwayjs/midway-component/issues/26) check the route info is iterable or not ([#27](https://github.com/midwayjs/midway-component/issues/27)) ([f0d4798](https://github.com/midwayjs/midway-component/commit/f0d479832aef0b558bfeac04b32a28cc83192810))
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## [1.0.6](https://github.com/midwayjs/midway-component/compare/@midwayjs/swagger@1.0.5...@midwayjs/swagger@1.0.6) (2020-12-09)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### Bug Fixes
|
|
21
|
-
|
|
22
|
-
* array type with rule decorator ([#22](https://github.com/midwayjs/midway-component/issues/22)) ([f3b1164](https://github.com/midwayjs/midway-component/commit/f3b1164381b5c02b1d1192acfaf30f01bb34650a))
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
## [1.0.5](https://github.com/midwayjs/midway-component/compare/@midwayjs/swagger@1.0.4...@midwayjs/swagger@1.0.5) (2020-12-02)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
### Bug Fixes
|
|
32
|
-
|
|
33
|
-
* swagger display problem when reponse=object、json ([#21](https://github.com/midwayjs/midway-component/issues/21)) ([2f65f2c](https://github.com/midwayjs/midway-component/commit/2f65f2c4334539fcf55fd5fd014646b12de35aa9))
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
## [1.0.4](https://github.com/midwayjs/midway-component/compare/@midwayjs/swagger@1.0.3...@midwayjs/swagger@1.0.4) (2020-11-23)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
### Bug Fixes
|
|
43
|
-
|
|
44
|
-
* body and property ([#19](https://github.com/midwayjs/midway-component/issues/19)) ([aca5185](https://github.com/midwayjs/midway-component/commit/aca51852b7f35c8d541d25e4d90ccacb27b7d2c7))
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
## [1.0.3](https://github.com/midwayjs/midway-component/compare/@midwayjs/swagger@1.0.2...@midwayjs/swagger@1.0.3) (2020-11-17)
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
### Bug Fixes
|
|
54
|
-
|
|
55
|
-
* missing response content ([#17](https://github.com/midwayjs/midway-component/issues/17)) ([057a77b](https://github.com/midwayjs/midway-component/commit/057a77bbb81f94d50aa586f75dde717daee373d6))
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
## [1.0.2](https://github.com/midwayjs/midway-component/compare/@midwayjs/swagger@1.0.1...@midwayjs/swagger@1.0.2) (2020-11-10)
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
### Bug Fixes
|
|
65
|
-
|
|
66
|
-
* npe and header render in swagger ([#15](https://github.com/midwayjs/midway-component/issues/15)) ([7b6b674](https://github.com/midwayjs/midway-component/commit/7b6b6743942897905cce91f657bebce989a646dc))
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
## [1.0.1](https://github.com/midwayjs/midway-component/compare/@midwayjs/swagger@1.0.0...@midwayjs/swagger@1.0.1) (2020-11-02)
|
|
73
|
-
|
|
74
|
-
**Note:** Version bump only for package @midwayjs/swagger
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
# [1.0.0](https://github.com/midwayjs/midway-component/compare/@midwayjs/swagger@1.0.0-beta.6...@midwayjs/swagger@1.0.0) (2020-10-29)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
### Features
|
|
84
|
-
|
|
85
|
-
* add config for swagger ([#13](https://github.com/midwayjs/midway-component/issues/13)) ([b72463c](https://github.com/midwayjs/midway-component/commit/b72463c6ab52cf5adff0c185d3a1752a6510690e))
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
# [1.0.0-beta.6](https://github.com/midwayjs/midway-component/compare/@midwayjs/swagger@1.0.0-beta.4...@midwayjs/swagger@1.0.0-beta.6) (2020-10-27)
|
|
92
|
-
|
|
93
|
-
**Note:** Version bump only for package @midwayjs/swagger
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
# 1.0.0-beta.4 (2020-10-23)
|
|
6
|
+
# [3.0.0-beta.10](https://github.com/midwayjs/midway/compare/v3.0.0-beta.9...v3.0.0-beta.10) (2021-12-20)
|
|
100
7
|
|
|
101
8
|
|
|
102
9
|
### Features
|
|
103
10
|
|
|
104
|
-
*
|
|
11
|
+
* 3.x swagger ([#1409](https://github.com/midwayjs/midway/issues/1409)) ([e00fbbf](https://github.com/midwayjs/midway/commit/e00fbbf7a494f300a53f3bd8635966364cfd96a9))
|
|
12
|
+
* add swagger doc & fix bug ([#1427](https://github.com/midwayjs/midway/issues/1427)) ([82dc6f1](https://github.com/midwayjs/midway/commit/82dc6f10f7244a75f58922edda1b0625fc6cb90e))
|
|
13
|
+
* support express ([61e73db](https://github.com/midwayjs/midway/commit/61e73db509bfea21c8251855fccb02a4ce09988f))
|
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.
|
package/README.md
CHANGED
|
@@ -1,28 +1,14 @@
|
|
|
1
|
-
#
|
|
1
|
+
# midwayjs swagger module
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## Thanks to [@nestjs/swagger](https://github.com/nestjs/swagger)
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
npm install swagger-ui-dist --save-dev // If you view swagger documentation on in local env
|
|
5
|
+
[](http://packagequality.com/#?package=midway-core)
|
|
6
|
+
[](https://github.com/midwayjs/midway/pulls)
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
```
|
|
8
|
+
this is a sub package for midway.
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
Document: [https://midwayjs.org/midway](https://midwayjs.org/midway)
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
## License
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
- [x] api args name
|
|
18
|
-
- [x] api tag(prefix)
|
|
19
|
-
- [x] api args type
|
|
20
|
-
- [x] DTO generate definition schema
|
|
21
|
-
- [x] body(object)
|
|
22
|
-
|
|
23
|
-
**Need add Code**
|
|
24
|
-
|
|
25
|
-
- [x] api description and summary
|
|
26
|
-
- [x] api args required
|
|
27
|
-
- [x] api args example
|
|
28
|
-
- [x] api response code and result format
|
|
14
|
+
[MIT]((http://github.com/midwayjs/midway/blob/master/LICENSE))
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SchemaObjectMetadata, SwaggerEnumType } from '../interfaces';
|
|
2
|
+
export declare function getEnumValues(enumType: SwaggerEnumType): string[] | number[];
|
|
3
|
+
export declare function getEnumType(values: (string | number)[]): 'string' | 'number';
|
|
4
|
+
export declare function addEnumArraySchema(paramDefinition: Partial<Record<'schema' | 'isArray' | 'enumName', any>>, decoratorOptions: Partial<Record<'enum' | 'enumName', any>>): void;
|
|
5
|
+
export declare function addEnumSchema(paramDefinition: Partial<Record<string, any>>, decoratorOptions: Partial<Record<string, any>>): void;
|
|
6
|
+
export declare const isEnumArray: <T extends Partial<Record<"enum" | "isArray", any>>>(obj: Record<string, any>) => obj is T;
|
|
7
|
+
export declare const isEnumDefined: <T extends Partial<Record<"enum", any>>>(obj: Record<string, any>) => obj is T;
|
|
8
|
+
export declare const isEnumMetadata: (metadata: SchemaObjectMetadata) => any;
|
|
9
|
+
//# sourceMappingURL=enum.utils.d.ts.map
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isEnumMetadata = exports.isEnumDefined = exports.isEnumArray = exports.addEnumSchema = exports.addEnumArraySchema = exports.getEnumType = exports.getEnumValues = void 0;
|
|
4
|
+
function getEnumValues(enumType) {
|
|
5
|
+
if (Array.isArray(enumType)) {
|
|
6
|
+
return enumType;
|
|
7
|
+
}
|
|
8
|
+
if (typeof enumType !== 'object') {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const values = [];
|
|
12
|
+
const uniqueValues = {};
|
|
13
|
+
for (const key in enumType) {
|
|
14
|
+
const value = enumType[key];
|
|
15
|
+
/* eslint-disable no-prototype-builtins */
|
|
16
|
+
// filter out cases where enum key also becomes its value (A: B, B: A)
|
|
17
|
+
if (!uniqueValues.hasOwnProperty(value) &&
|
|
18
|
+
!uniqueValues.hasOwnProperty(key)) {
|
|
19
|
+
values.push(value);
|
|
20
|
+
uniqueValues[value] = value;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return values;
|
|
24
|
+
}
|
|
25
|
+
exports.getEnumValues = getEnumValues;
|
|
26
|
+
function getEnumType(values) {
|
|
27
|
+
const hasString = values.filter(s => typeof s === 'string').length > 0;
|
|
28
|
+
return hasString ? 'string' : 'number';
|
|
29
|
+
}
|
|
30
|
+
exports.getEnumType = getEnumType;
|
|
31
|
+
function addEnumArraySchema(paramDefinition, decoratorOptions) {
|
|
32
|
+
const paramSchema = paramDefinition.schema || {};
|
|
33
|
+
paramDefinition.schema = paramSchema;
|
|
34
|
+
paramSchema.type = 'array';
|
|
35
|
+
delete paramDefinition.isArray;
|
|
36
|
+
const enumValues = getEnumValues(decoratorOptions.enum);
|
|
37
|
+
paramSchema.items = {
|
|
38
|
+
type: getEnumType(enumValues),
|
|
39
|
+
enum: enumValues,
|
|
40
|
+
};
|
|
41
|
+
if (decoratorOptions.enumName) {
|
|
42
|
+
paramDefinition.enumName = decoratorOptions.enumName;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.addEnumArraySchema = addEnumArraySchema;
|
|
46
|
+
function addEnumSchema(paramDefinition, decoratorOptions) {
|
|
47
|
+
const paramSchema = paramDefinition.schema || {};
|
|
48
|
+
const enumValues = getEnumValues(decoratorOptions.enum);
|
|
49
|
+
paramDefinition.schema = paramSchema;
|
|
50
|
+
paramSchema.enum = enumValues;
|
|
51
|
+
paramSchema.type = getEnumType(enumValues);
|
|
52
|
+
if (decoratorOptions.enumName) {
|
|
53
|
+
paramDefinition.enumName = decoratorOptions.enumName;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.addEnumSchema = addEnumSchema;
|
|
57
|
+
const isEnumArray = (obj) => obj.isArray && obj.enum;
|
|
58
|
+
exports.isEnumArray = isEnumArray;
|
|
59
|
+
const isEnumDefined = (obj) => obj.enum;
|
|
60
|
+
exports.isEnumDefined = isEnumDefined;
|
|
61
|
+
const isEnumMetadata = (metadata) => { var _a; return metadata.enum || (metadata.isArray && ((_a = metadata.items) === null || _a === void 0 ? void 0 : _a['enum'])); };
|
|
62
|
+
exports.isEnumMetadata = isEnumMetadata;
|
|
63
|
+
//# sourceMappingURL=enum.utils.js.map
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export declare enum HttpStatus {
|
|
2
|
+
CONTINUE = 100,
|
|
3
|
+
SWITCHING_PROTOCOLS = 101,
|
|
4
|
+
PROCESSING = 102,
|
|
5
|
+
EARLYHINTS = 103,
|
|
6
|
+
OK = 200,
|
|
7
|
+
CREATED = 201,
|
|
8
|
+
ACCEPTED = 202,
|
|
9
|
+
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
10
|
+
NO_CONTENT = 204,
|
|
11
|
+
RESET_CONTENT = 205,
|
|
12
|
+
PARTIAL_CONTENT = 206,
|
|
13
|
+
AMBIGUOUS = 300,
|
|
14
|
+
MOVED_PERMANENTLY = 301,
|
|
15
|
+
FOUND = 302,
|
|
16
|
+
SEE_OTHER = 303,
|
|
17
|
+
NOT_MODIFIED = 304,
|
|
18
|
+
TEMPORARY_REDIRECT = 307,
|
|
19
|
+
PERMANENT_REDIRECT = 308,
|
|
20
|
+
BAD_REQUEST = 400,
|
|
21
|
+
UNAUTHORIZED = 401,
|
|
22
|
+
PAYMENT_REQUIRED = 402,
|
|
23
|
+
FORBIDDEN = 403,
|
|
24
|
+
NOT_FOUND = 404,
|
|
25
|
+
METHOD_NOT_ALLOWED = 405,
|
|
26
|
+
NOT_ACCEPTABLE = 406,
|
|
27
|
+
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
28
|
+
REQUEST_TIMEOUT = 408,
|
|
29
|
+
CONFLICT = 409,
|
|
30
|
+
GONE = 410,
|
|
31
|
+
LENGTH_REQUIRED = 411,
|
|
32
|
+
PRECONDITION_FAILED = 412,
|
|
33
|
+
PAYLOAD_TOO_LARGE = 413,
|
|
34
|
+
URI_TOO_LONG = 414,
|
|
35
|
+
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
36
|
+
REQUESTED_RANGE_NOT_SATISFIABLE = 416,
|
|
37
|
+
EXPECTATION_FAILED = 417,
|
|
38
|
+
I_AM_A_TEAPOT = 418,
|
|
39
|
+
MISDIRECTED = 421,
|
|
40
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
41
|
+
FAILED_DEPENDENCY = 424,
|
|
42
|
+
PRECONDITION_REQUIRED = 428,
|
|
43
|
+
TOO_MANY_REQUESTS = 429,
|
|
44
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
45
|
+
NOT_IMPLEMENTED = 501,
|
|
46
|
+
BAD_GATEWAY = 502,
|
|
47
|
+
SERVICE_UNAVAILABLE = 503,
|
|
48
|
+
GATEWAY_TIMEOUT = 504,
|
|
49
|
+
HTTP_VERSION_NOT_SUPPORTED = 505
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=httpStatus.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpStatus = void 0;
|
|
4
|
+
var HttpStatus;
|
|
5
|
+
(function (HttpStatus) {
|
|
6
|
+
HttpStatus[HttpStatus["CONTINUE"] = 100] = "CONTINUE";
|
|
7
|
+
HttpStatus[HttpStatus["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
|
|
8
|
+
HttpStatus[HttpStatus["PROCESSING"] = 102] = "PROCESSING";
|
|
9
|
+
HttpStatus[HttpStatus["EARLYHINTS"] = 103] = "EARLYHINTS";
|
|
10
|
+
HttpStatus[HttpStatus["OK"] = 200] = "OK";
|
|
11
|
+
HttpStatus[HttpStatus["CREATED"] = 201] = "CREATED";
|
|
12
|
+
HttpStatus[HttpStatus["ACCEPTED"] = 202] = "ACCEPTED";
|
|
13
|
+
HttpStatus[HttpStatus["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
|
|
14
|
+
HttpStatus[HttpStatus["NO_CONTENT"] = 204] = "NO_CONTENT";
|
|
15
|
+
HttpStatus[HttpStatus["RESET_CONTENT"] = 205] = "RESET_CONTENT";
|
|
16
|
+
HttpStatus[HttpStatus["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
|
|
17
|
+
HttpStatus[HttpStatus["AMBIGUOUS"] = 300] = "AMBIGUOUS";
|
|
18
|
+
HttpStatus[HttpStatus["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
|
|
19
|
+
HttpStatus[HttpStatus["FOUND"] = 302] = "FOUND";
|
|
20
|
+
HttpStatus[HttpStatus["SEE_OTHER"] = 303] = "SEE_OTHER";
|
|
21
|
+
HttpStatus[HttpStatus["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
|
|
22
|
+
HttpStatus[HttpStatus["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
|
|
23
|
+
HttpStatus[HttpStatus["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
|
|
24
|
+
HttpStatus[HttpStatus["BAD_REQUEST"] = 400] = "BAD_REQUEST";
|
|
25
|
+
HttpStatus[HttpStatus["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
|
|
26
|
+
HttpStatus[HttpStatus["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
|
|
27
|
+
HttpStatus[HttpStatus["FORBIDDEN"] = 403] = "FORBIDDEN";
|
|
28
|
+
HttpStatus[HttpStatus["NOT_FOUND"] = 404] = "NOT_FOUND";
|
|
29
|
+
HttpStatus[HttpStatus["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
|
|
30
|
+
HttpStatus[HttpStatus["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
|
|
31
|
+
HttpStatus[HttpStatus["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
|
|
32
|
+
HttpStatus[HttpStatus["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
|
|
33
|
+
HttpStatus[HttpStatus["CONFLICT"] = 409] = "CONFLICT";
|
|
34
|
+
HttpStatus[HttpStatus["GONE"] = 410] = "GONE";
|
|
35
|
+
HttpStatus[HttpStatus["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
|
|
36
|
+
HttpStatus[HttpStatus["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
|
|
37
|
+
HttpStatus[HttpStatus["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
|
|
38
|
+
HttpStatus[HttpStatus["URI_TOO_LONG"] = 414] = "URI_TOO_LONG";
|
|
39
|
+
HttpStatus[HttpStatus["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
|
|
40
|
+
HttpStatus[HttpStatus["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
|
|
41
|
+
HttpStatus[HttpStatus["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
|
|
42
|
+
HttpStatus[HttpStatus["I_AM_A_TEAPOT"] = 418] = "I_AM_A_TEAPOT";
|
|
43
|
+
HttpStatus[HttpStatus["MISDIRECTED"] = 421] = "MISDIRECTED";
|
|
44
|
+
HttpStatus[HttpStatus["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
|
|
45
|
+
HttpStatus[HttpStatus["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
|
|
46
|
+
HttpStatus[HttpStatus["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
|
|
47
|
+
HttpStatus[HttpStatus["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
|
|
48
|
+
HttpStatus[HttpStatus["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
|
|
49
|
+
HttpStatus[HttpStatus["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
|
|
50
|
+
HttpStatus[HttpStatus["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
|
|
51
|
+
HttpStatus[HttpStatus["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
|
|
52
|
+
HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
|
|
53
|
+
HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
|
|
54
|
+
})(HttpStatus = exports.HttpStatus || (exports.HttpStatus = {}));
|
|
55
|
+
//# sourceMappingURL=httpStatus.js.map
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
title: string;
|
|
4
|
-
description: string;
|
|
5
|
-
version: string;
|
|
6
|
-
};
|
|
7
|
-
};
|
|
8
|
-
export default _default;
|
|
1
|
+
import { SwaggerOptions } from '../interfaces';
|
|
2
|
+
export declare const swagger: SwaggerOptions;
|
|
9
3
|
//# sourceMappingURL=config.default.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
exports.swagger = void 0;
|
|
4
|
+
exports.swagger = {
|
|
5
|
+
title: 'My Project',
|
|
6
|
+
description: 'This is a swagger-ui for midwayjs project',
|
|
7
|
+
version: '1.0.0',
|
|
8
|
+
swaggerPath: '/swagger-ui',
|
|
9
9
|
};
|
|
10
10
|
//# sourceMappingURL=config.default.js.map
|
package/dist/configuration.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { ILifeCycle, IMidwayContainer, MidwayApplicationManager } from '@midwayjs/core';
|
|
2
|
+
export declare class SwaggerConfiguration implements ILifeCycle {
|
|
3
|
+
applicationManager: MidwayApplicationManager;
|
|
4
|
+
onReady(container: IMidwayContainer): Promise<void>;
|
|
3
5
|
}
|
|
4
6
|
//# sourceMappingURL=configuration.d.ts.map
|
package/dist/configuration.js
CHANGED
|
@@ -5,23 +5,39 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
8
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
12
|
+
exports.SwaggerConfiguration = void 0;
|
|
13
|
+
const core_1 = require("@midwayjs/core");
|
|
10
14
|
const decorator_1 = require("@midwayjs/decorator");
|
|
11
|
-
const
|
|
12
|
-
|
|
15
|
+
const _1 = require(".");
|
|
16
|
+
const DefaultConfig = require("./config/config.default");
|
|
17
|
+
let SwaggerConfiguration = class SwaggerConfiguration {
|
|
13
18
|
async onReady(container) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
this.applicationManager
|
|
20
|
+
.getApplications(['express', 'koa', 'egg', 'faas'])
|
|
21
|
+
.forEach(app => {
|
|
22
|
+
app.useMiddleware(_1.SwaggerMiddleware);
|
|
23
|
+
});
|
|
24
|
+
const explorer = await container.getAsync(_1.SwaggerExplorer);
|
|
25
|
+
explorer.scanApp();
|
|
18
26
|
}
|
|
19
27
|
};
|
|
20
|
-
|
|
21
|
-
decorator_1.
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, decorator_1.Inject)(),
|
|
30
|
+
__metadata("design:type", core_1.MidwayApplicationManager)
|
|
31
|
+
], SwaggerConfiguration.prototype, "applicationManager", void 0);
|
|
32
|
+
SwaggerConfiguration = __decorate([
|
|
33
|
+
(0, decorator_1.Configuration)({
|
|
34
|
+
importConfigs: [
|
|
35
|
+
{
|
|
36
|
+
default: DefaultConfig,
|
|
37
|
+
},
|
|
38
|
+
],
|
|
22
39
|
namespace: 'swagger',
|
|
23
|
-
importConfigs: [path_1.join(__dirname, 'config')],
|
|
24
40
|
})
|
|
25
|
-
],
|
|
26
|
-
exports.
|
|
41
|
+
], SwaggerConfiguration);
|
|
42
|
+
exports.SwaggerConfiguration = SwaggerConfiguration;
|
|
27
43
|
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const DECORATORS_PREFIX = "swagger";
|
|
2
|
+
export declare const DECORATORS: {
|
|
3
|
+
API_OPERATION: string;
|
|
4
|
+
API_RESPONSE: string;
|
|
5
|
+
API_TAGS: string;
|
|
6
|
+
API_PARAMETERS: string;
|
|
7
|
+
API_HEADERS: string;
|
|
8
|
+
API_MODEL_PROPERTIES: string;
|
|
9
|
+
API_MODEL_PROPERTIES_ARRAY: string;
|
|
10
|
+
API_SECURITY: string;
|
|
11
|
+
API_EXCLUDE_ENDPOINT: string;
|
|
12
|
+
API_EXCLUDE_CONTROLLER: string;
|
|
13
|
+
API_EXTENSION: string;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DECORATORS = exports.DECORATORS_PREFIX = void 0;
|
|
4
|
+
exports.DECORATORS_PREFIX = 'swagger';
|
|
5
|
+
exports.DECORATORS = {
|
|
6
|
+
API_OPERATION: `${exports.DECORATORS_PREFIX}/apiOperation`,
|
|
7
|
+
API_RESPONSE: `${exports.DECORATORS_PREFIX}/apiResponse`,
|
|
8
|
+
API_TAGS: `${exports.DECORATORS_PREFIX}/apiUseTags`,
|
|
9
|
+
API_PARAMETERS: `${exports.DECORATORS_PREFIX}/apiParameters`,
|
|
10
|
+
API_HEADERS: `${exports.DECORATORS_PREFIX}/apiHeaders`,
|
|
11
|
+
API_MODEL_PROPERTIES: `${exports.DECORATORS_PREFIX}/apiModelProperties`,
|
|
12
|
+
API_MODEL_PROPERTIES_ARRAY: `${exports.DECORATORS_PREFIX}/apiModelPropertiesArray`,
|
|
13
|
+
API_SECURITY: `${exports.DECORATORS_PREFIX}/apiSecurity`,
|
|
14
|
+
API_EXCLUDE_ENDPOINT: `${exports.DECORATORS_PREFIX}/apiExcludeEndpoint`,
|
|
15
|
+
API_EXCLUDE_CONTROLLER: `${exports.DECORATORS_PREFIX}/apiExcludeController`,
|
|
16
|
+
API_EXTENSION: `${exports.DECORATORS_PREFIX}/apiExtension`,
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiBasicAuth = void 0;
|
|
4
|
+
const api_security_decorator_1 = require("./api-security.decorator");
|
|
5
|
+
function ApiBasicAuth(name = 'basic') {
|
|
6
|
+
return (0, api_security_decorator_1.ApiSecurity)(name);
|
|
7
|
+
}
|
|
8
|
+
exports.ApiBasicAuth = ApiBasicAuth;
|
|
9
|
+
//# sourceMappingURL=api-basic.decorator.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiBearerAuth = void 0;
|
|
4
|
+
const api_security_decorator_1 = require("./api-security.decorator");
|
|
5
|
+
function ApiBearerAuth(name = 'bearer') {
|
|
6
|
+
return (0, api_security_decorator_1.ApiSecurity)(name);
|
|
7
|
+
}
|
|
8
|
+
exports.ApiBearerAuth = ApiBearerAuth;
|
|
9
|
+
//# sourceMappingURL=api-bearer.decorator.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ContentObject, ExamplesObject, ReferenceObject, RequestBodyObject, SchemaObject, SwaggerEnumType } from '../interfaces';
|
|
2
|
+
declare type RequestBodyOptions = Omit<RequestBodyObject, 'content'>;
|
|
3
|
+
interface ApiBodyMetadata extends RequestBodyOptions {
|
|
4
|
+
type?: any;
|
|
5
|
+
isArray?: boolean;
|
|
6
|
+
enum?: SwaggerEnumType;
|
|
7
|
+
content?: ContentObject;
|
|
8
|
+
}
|
|
9
|
+
interface ApiBodySchemaHost extends RequestBodyOptions {
|
|
10
|
+
schema: SchemaObject | ReferenceObject;
|
|
11
|
+
examples?: ExamplesObject;
|
|
12
|
+
}
|
|
13
|
+
export declare type ApiBodyOptions = ApiBodyMetadata | ApiBodySchemaHost;
|
|
14
|
+
export declare function ApiBody(options: ApiBodyOptions): MethodDecorator;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=api-body.decorator.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiBody = void 0;
|
|
4
|
+
const enum_utils_1 = require("../common/enum.utils");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
const defaultBodyMetadata = {
|
|
7
|
+
type: String,
|
|
8
|
+
required: true,
|
|
9
|
+
};
|
|
10
|
+
function ApiBody(options) {
|
|
11
|
+
const [type, isArray] = (0, helpers_1.getTypeIsArrayTuple)(options.type, options.isArray);
|
|
12
|
+
const param = {
|
|
13
|
+
in: 'body',
|
|
14
|
+
...options,
|
|
15
|
+
type,
|
|
16
|
+
isArray,
|
|
17
|
+
};
|
|
18
|
+
if ((0, enum_utils_1.isEnumArray)(options)) {
|
|
19
|
+
(0, enum_utils_1.addEnumArraySchema)(param, options);
|
|
20
|
+
}
|
|
21
|
+
else if ((0, enum_utils_1.isEnumDefined)(options)) {
|
|
22
|
+
(0, enum_utils_1.addEnumSchema)(param, options);
|
|
23
|
+
}
|
|
24
|
+
return (0, helpers_1.createParamDecorator)(param, defaultBodyMetadata);
|
|
25
|
+
}
|
|
26
|
+
exports.ApiBody = ApiBody;
|
|
27
|
+
//# sourceMappingURL=api-body.decorator.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiCookieAuth = void 0;
|
|
4
|
+
const api_security_decorator_1 = require("./api-security.decorator");
|
|
5
|
+
function ApiCookieAuth(name = 'cookie') {
|
|
6
|
+
return (0, api_security_decorator_1.ApiSecurity)(name);
|
|
7
|
+
}
|
|
8
|
+
exports.ApiCookieAuth = ApiCookieAuth;
|
|
9
|
+
//# sourceMappingURL=api-cookie.decorator.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiExcludeController = void 0;
|
|
4
|
+
const decorator_1 = require("@midwayjs/decorator");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function ApiExcludeController(disable = true) {
|
|
7
|
+
return (0, decorator_1.createCustomMethodDecorator)(constants_1.DECORATORS.API_EXCLUDE_CONTROLLER, [
|
|
8
|
+
disable,
|
|
9
|
+
]);
|
|
10
|
+
}
|
|
11
|
+
exports.ApiExcludeController = ApiExcludeController;
|
|
12
|
+
//# sourceMappingURL=api-exclude-controller.decorator.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiExcludeEndpoint = void 0;
|
|
4
|
+
const decorator_1 = require("@midwayjs/decorator");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
|
+
function ApiExcludeEndpoint(disable = true) {
|
|
7
|
+
return (0, decorator_1.createCustomMethodDecorator)(constants_1.DECORATORS.API_EXCLUDE_ENDPOINT, {
|
|
8
|
+
disable,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.ApiExcludeEndpoint = ApiExcludeEndpoint;
|
|
12
|
+
//# sourceMappingURL=api-exclude-endpoint.decorator.js.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiExtension = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const helpers_1 = require("./helpers");
|
|
6
|
+
function ApiExtension(extensionKey, extensionProperties) {
|
|
7
|
+
if (!extensionKey.startsWith('x-')) {
|
|
8
|
+
throw new Error('Extension key is not prefixed. Please ensure you prefix it with `x-`.');
|
|
9
|
+
}
|
|
10
|
+
const extensionObject = {
|
|
11
|
+
[extensionKey]: JSON.parse(JSON.stringify(extensionProperties)),
|
|
12
|
+
};
|
|
13
|
+
return (0, helpers_1.createMixedDecorator)(constants_1.DECORATORS.API_EXTENSION, extensionObject);
|
|
14
|
+
}
|
|
15
|
+
exports.ApiExtension = ApiExtension;
|
|
16
|
+
//# sourceMappingURL=api-extension.decorator.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { SwaggerEnumType, ParameterObject } from '../interfaces';
|
|
2
|
+
export interface ApiHeaderOptions extends Omit<ParameterObject, 'in'> {
|
|
3
|
+
enum?: SwaggerEnumType;
|
|
4
|
+
}
|
|
5
|
+
export declare function ApiHeader(options: ApiHeaderOptions): any;
|
|
6
|
+
export declare const ApiHeaders: (headers: ApiHeaderOptions[]) => MethodDecorator & ClassDecorator;
|
|
7
|
+
//# sourceMappingURL=api-header.decorator.d.ts.map
|