@midwayjs/swagger 1.2.0 → 3.0.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +9 -75
  2. package/LICENSE +21 -0
  3. package/README.md +8 -22
  4. package/dist/common/enum.utils.d.ts +9 -0
  5. package/dist/common/enum.utils.js +63 -0
  6. package/dist/common/httpStatus.d.ts +51 -0
  7. package/dist/common/httpStatus.js +55 -0
  8. package/dist/config/config.default.d.ts +2 -8
  9. package/dist/config/config.default.js +6 -6
  10. package/dist/configuration.d.ts +4 -2
  11. package/dist/configuration.js +27 -11
  12. package/dist/constants.d.ts +15 -0
  13. package/dist/constants.js +18 -0
  14. package/dist/decorators/api-basic.decorator.d.ts +2 -0
  15. package/dist/decorators/api-basic.decorator.js +9 -0
  16. package/dist/decorators/api-bearer.decorator.d.ts +2 -0
  17. package/dist/decorators/api-bearer.decorator.js +9 -0
  18. package/dist/decorators/api-body.decorator.d.ts +24 -0
  19. package/dist/decorators/api-body.decorator.js +35 -0
  20. package/dist/decorators/api-cookie.decorator.d.ts +2 -0
  21. package/dist/decorators/api-cookie.decorator.js +9 -0
  22. package/dist/decorators/api-exclude-controller.decorator.d.ts +2 -0
  23. package/dist/decorators/api-exclude-controller.decorator.js +12 -0
  24. package/dist/decorators/api-exclude-endpoint.decorator.d.ts +2 -0
  25. package/dist/decorators/api-exclude-endpoint.decorator.js +12 -0
  26. package/dist/decorators/api-extension.decorator.d.ts +2 -0
  27. package/dist/decorators/api-extension.decorator.js +16 -0
  28. package/dist/decorators/api-header.decorator.d.ts +7 -0
  29. package/dist/decorators/api-header.decorator.js +43 -0
  30. package/dist/decorators/api-oauth2.decorator.d.ts +2 -0
  31. package/dist/decorators/api-oauth2.decorator.js +9 -0
  32. package/dist/decorators/api-operation.decorator.d.ts +4 -0
  33. package/dist/decorators/api-operation.decorator.js +16 -0
  34. package/dist/decorators/api-param.decorator.d.ts +15 -0
  35. package/dist/decorators/api-param.decorator.js +30 -0
  36. package/dist/decorators/api-property.decorator.d.ts +11 -0
  37. package/dist/decorators/api-property.decorator.js +55 -0
  38. package/dist/decorators/api-query.decorator.d.ts +17 -0
  39. package/dist/decorators/api-query.decorator.js +31 -0
  40. package/dist/decorators/api-response.decorator.d.ts +41 -0
  41. package/dist/decorators/api-response.decorator.js +149 -0
  42. package/dist/decorators/api-security.decorator.d.ts +3 -0
  43. package/dist/decorators/api-security.decorator.js +17 -0
  44. package/dist/decorators/api-tags.decorator.d.ts +2 -0
  45. package/dist/decorators/api-tags.decorator.js +10 -0
  46. package/dist/decorators/helpers.d.ts +7 -0
  47. package/dist/decorators/helpers.js +41 -0
  48. package/dist/decorators/index.d.ts +18 -0
  49. package/dist/decorators/index.js +35 -0
  50. package/dist/documentBuilder.d.ts +25 -0
  51. package/dist/documentBuilder.js +192 -0
  52. package/dist/index.d.ts +5 -5
  53. package/dist/index.js +8 -6
  54. package/dist/interfaces/index.d.ts +339 -0
  55. package/dist/interfaces/index.js +7 -0
  56. package/dist/swaggerExplorer.d.ts +30 -0
  57. package/dist/swaggerExplorer.js +601 -0
  58. package/dist/swaggerMiddleware.d.ts +10 -0
  59. package/dist/swaggerMiddleware.js +126 -0
  60. package/index.d.ts +8 -0
  61. package/package.json +12 -10
  62. package/dist/controller/swagger.d.ts +0 -31
  63. package/dist/controller/swagger.js +0 -96
  64. package/dist/interface.d.ts +0 -16
  65. package/dist/interface.js +0 -3
  66. package/dist/lib/createAPI.d.ts +0 -52
  67. package/dist/lib/createAPI.js +0 -276
  68. package/dist/lib/document.d.ts +0 -117
  69. package/dist/lib/document.js +0 -131
  70. package/dist/lib/generator.d.ts +0 -31
  71. package/dist/lib/generator.js +0 -310
  72. package/dist/service/generator.d.ts +0 -24
  73. package/dist/service/generator.js +0 -37
package/CHANGELOG.md CHANGED
@@ -3,92 +3,24 @@
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
- ## [1.0.7](https://github.com/midwayjs/midway-component/compare/@midwayjs/swagger@1.0.6...@midwayjs/swagger@1.0.7) (2021-03-22)
6
+ # [3.0.0-beta.12](https://github.com/midwayjs/midway/compare/v3.0.0-beta.11...v3.0.0-beta.12) (2021-12-28)
7
7
 
8
8
 
9
9
  ### Bug Fixes
10
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)
11
+ * 3.x copy all properties ([#1444](https://github.com/midwayjs/midway/issues/1444)) ([21ec8b6](https://github.com/midwayjs/midway/commit/21ec8b6a85b6ba3f4fbff0c8a571484aaa078788))
81
12
 
82
13
 
83
14
  ### Features
84
15
 
85
- * add config for swagger ([#13](https://github.com/midwayjs/midway-component/issues/13)) ([b72463c](https://github.com/midwayjs/midway-component/commit/b72463c6ab52cf5adff0c185d3a1752a6510690e))
16
+ * add fileupload support ([#1439](https://github.com/midwayjs/midway/issues/1439)) ([0a81e72](https://github.com/midwayjs/midway/commit/0a81e720f525ddab0718301f44f80fce376f9bfe))
17
+ * support throw err status ([#1440](https://github.com/midwayjs/midway/issues/1440)) ([7b98110](https://github.com/midwayjs/midway/commit/7b98110d65c5287a8fcb3eb5356dea2d7a32cee9))
86
18
 
87
19
 
88
20
 
89
21
 
90
22
 
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)
23
+ # [3.0.0-beta.11](https://github.com/midwayjs/midway/compare/v3.0.0-beta.10...v3.0.0-beta.11) (2021-12-21)
92
24
 
93
25
  **Note:** Version bump only for package @midwayjs/swagger
94
26
 
@@ -96,9 +28,11 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
96
28
 
97
29
 
98
30
 
99
- # 1.0.0-beta.4 (2020-10-23)
31
+ # [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
32
 
101
33
 
102
34
  ### Features
103
35
 
104
- * add swagger ([#11](https://github.com/midwayjs/midway-component/issues/11)) ([7c8daa5](https://github.com/midwayjs/midway-component/commit/7c8daa5b23eaf688b967f5199b6353a69f482e9f))
36
+ * 3.x swagger ([#1409](https://github.com/midwayjs/midway/issues/1409)) ([e00fbbf](https://github.com/midwayjs/midway/commit/e00fbbf7a494f300a53f3bd8635966364cfd96a9))
37
+ * add swagger doc & fix bug ([#1427](https://github.com/midwayjs/midway/issues/1427)) ([82dc6f1](https://github.com/midwayjs/midway/commit/82dc6f10f7244a75f58922edda1b0625fc6cb90e))
38
+ * 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
- # midway swagger component
1
+ # midwayjs swagger module
2
2
 
3
- ## How to use
3
+ ## Thanks to [@nestjs/swagger](https://github.com/nestjs/swagger)
4
4
 
5
- ```js
6
- npm install @midwayjs/swagger --save
7
- npm install swagger-ui-dist --save-dev // If you view swagger documentation on in local env
5
+ [![Package Quality](http://npm.packagequality.com/shield/midway-core.svg)](http://packagequality.com/#?package=midway-core)
6
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/midwayjs/midway/pulls)
8
7
 
9
- npm install swagger-ui-dist --save // If you want view swagger documentation on the server
10
- ```
8
+ this is a sub package for midway.
11
9
 
12
- ## Support
10
+ Document: [https://midwayjs.org/midway](https://midwayjs.org/midway)
13
11
 
14
- **Default and Auto**
12
+ ## License
15
13
 
16
- - [x] api name
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
- declare const _default: {
2
- swagger: {
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.default = {
4
- swagger: {
5
- title: 'My Project',
6
- description: 'This is a swagger-ui for midwayjs project',
7
- version: '1.0.0',
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
@@ -1,4 +1,6 @@
1
- export declare class AutoConfiguration {
2
- onReady(container: any): Promise<void>;
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
@@ -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.AutoConfiguration = void 0;
12
+ exports.SwaggerConfiguration = void 0;
13
+ const core_1 = require("@midwayjs/core");
10
14
  const decorator_1 = require("@midwayjs/decorator");
11
- const path_1 = require("path");
12
- let AutoConfiguration = class AutoConfiguration {
15
+ const _1 = require(".");
16
+ const DefaultConfig = require("./config/config.default");
17
+ let SwaggerConfiguration = class SwaggerConfiguration {
13
18
  async onReady(container) {
14
- if (process.env.MIDWAY_SWAGGER_DEBUG === 'true') {
15
- const swaggerGenerator = await container.getAsync('swagger:swaggerGenerator');
16
- console.log(JSON.stringify(swaggerGenerator.generate()));
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
- AutoConfiguration = __decorate([
28
+ __decorate([
29
+ (0, decorator_1.Inject)(),
30
+ __metadata("design:type", core_1.MidwayApplicationManager)
31
+ ], SwaggerConfiguration.prototype, "applicationManager", void 0);
32
+ SwaggerConfiguration = __decorate([
21
33
  (0, decorator_1.Configuration)({
34
+ importConfigs: [
35
+ {
36
+ default: DefaultConfig,
37
+ },
38
+ ],
22
39
  namespace: 'swagger',
23
- importConfigs: [(0, path_1.join)(__dirname, 'config')],
24
40
  })
25
- ], AutoConfiguration);
26
- exports.AutoConfiguration = AutoConfiguration;
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,2 @@
1
+ export declare function ApiBasicAuth(name?: string): any;
2
+ //# sourceMappingURL=api-basic.decorator.d.ts.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,2 @@
1
+ export declare function ApiBearerAuth(name?: string): any;
2
+ //# sourceMappingURL=api-bearer.decorator.d.ts.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,24 @@
1
+ import { ContentObject, ExamplesObject, ReferenceObject, RequestBodyObject, SchemaObject, SwaggerEnumType } from '../interfaces';
2
+ declare type RequestBodyOptions = Omit<RequestBodyObject, 'content'>;
3
+ export declare enum BodyContentType {
4
+ FormUrlEncoded = "application/x-www-form-urlencoded",
5
+ JSON = "application/json",
6
+ Multipart = "multipart/form-data",
7
+ MultipartMixed = "multipart/mixed",
8
+ OctetStream = "application/octet-stream"
9
+ }
10
+ interface ApiBodyMetadata extends RequestBodyOptions {
11
+ type?: any;
12
+ isArray?: boolean;
13
+ enum?: SwaggerEnumType;
14
+ content?: ContentObject;
15
+ contentType?: BodyContentType;
16
+ }
17
+ interface ApiBodySchemaHost extends RequestBodyOptions {
18
+ schema: SchemaObject | ReferenceObject;
19
+ examples?: ExamplesObject;
20
+ }
21
+ export declare type ApiBodyOptions = ApiBodyMetadata | ApiBodySchemaHost;
22
+ export declare function ApiBody(options: ApiBodyOptions): MethodDecorator;
23
+ export {};
24
+ //# sourceMappingURL=api-body.decorator.d.ts.map
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiBody = exports.BodyContentType = void 0;
4
+ const enum_utils_1 = require("../common/enum.utils");
5
+ const helpers_1 = require("./helpers");
6
+ var BodyContentType;
7
+ (function (BodyContentType) {
8
+ BodyContentType["FormUrlEncoded"] = "application/x-www-form-urlencoded";
9
+ BodyContentType["JSON"] = "application/json";
10
+ BodyContentType["Multipart"] = "multipart/form-data";
11
+ BodyContentType["MultipartMixed"] = "multipart/mixed";
12
+ BodyContentType["OctetStream"] = "application/octet-stream";
13
+ })(BodyContentType = exports.BodyContentType || (exports.BodyContentType = {}));
14
+ const defaultBodyMetadata = {
15
+ type: String,
16
+ required: true,
17
+ };
18
+ function ApiBody(options) {
19
+ const [type, isArray] = (0, helpers_1.getTypeIsArrayTuple)(options.type, options.isArray);
20
+ const param = {
21
+ in: 'body',
22
+ ...options,
23
+ type,
24
+ isArray,
25
+ };
26
+ if ((0, enum_utils_1.isEnumArray)(options)) {
27
+ (0, enum_utils_1.addEnumArraySchema)(param, options);
28
+ }
29
+ else if ((0, enum_utils_1.isEnumDefined)(options)) {
30
+ (0, enum_utils_1.addEnumSchema)(param, options);
31
+ }
32
+ return (0, helpers_1.createParamDecorator)(param, defaultBodyMetadata);
33
+ }
34
+ exports.ApiBody = ApiBody;
35
+ //# sourceMappingURL=api-body.decorator.js.map
@@ -0,0 +1,2 @@
1
+ export declare function ApiCookieAuth(name?: string): any;
2
+ //# sourceMappingURL=api-cookie.decorator.d.ts.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,2 @@
1
+ export declare function ApiExcludeController(disable?: boolean): any;
2
+ //# sourceMappingURL=api-exclude-controller.decorator.d.ts.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,2 @@
1
+ export declare function ApiExcludeEndpoint(disable?: boolean): MethodDecorator;
2
+ //# sourceMappingURL=api-exclude-endpoint.decorator.d.ts.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,2 @@
1
+ export declare function ApiExtension(extensionKey: string, extensionProperties: any): any;
2
+ //# sourceMappingURL=api-extension.decorator.d.ts.map