@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
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DocumentBuilder = void 0;
4
+ class DocumentBuilder {
5
+ constructor() {
6
+ this.document = {
7
+ openapi: '3.0.1',
8
+ info: {
9
+ title: '',
10
+ description: '',
11
+ version: '1.0.0',
12
+ contact: {},
13
+ },
14
+ tags: [],
15
+ servers: [],
16
+ components: {},
17
+ paths: {},
18
+ };
19
+ }
20
+ setTitle(title) {
21
+ this.document.info.title = title;
22
+ return this;
23
+ }
24
+ setDescription(description) {
25
+ this.document.info.description = description;
26
+ return this;
27
+ }
28
+ setVersion(version) {
29
+ this.document.info.version = version;
30
+ return this;
31
+ }
32
+ setTermsOfService(termsOfService) {
33
+ this.document.info.termsOfService = termsOfService;
34
+ return this;
35
+ }
36
+ setContact(name, url, email) {
37
+ this.document.info.contact = { name, url, email };
38
+ return this;
39
+ }
40
+ setLicense(name, url) {
41
+ this.document.info.license = { name, url };
42
+ return this;
43
+ }
44
+ addServer(url, description, variables) {
45
+ this.document.servers.push({ url, description, variables });
46
+ return this;
47
+ }
48
+ setExternalDoc(description, url) {
49
+ this.document.externalDocs = { description, url };
50
+ return this;
51
+ }
52
+ setBasePath(path) {
53
+ if (this.document.basePath) {
54
+ if (Array.isArray(this.document.basePath)) {
55
+ this.document.basePath.push(path);
56
+ }
57
+ else {
58
+ this.document.basePath = [
59
+ this.document.basePath,
60
+ path,
61
+ ];
62
+ }
63
+ }
64
+ else {
65
+ this.document.basePath = path;
66
+ }
67
+ return this;
68
+ }
69
+ addPaths(paths) {
70
+ Object.assign(this.document.paths, paths);
71
+ return this;
72
+ }
73
+ addSchema(schema) {
74
+ if (!this.document.components.schemas) {
75
+ this.document.components.schemas = {};
76
+ }
77
+ Object.assign(this.document.components.schemas, schema);
78
+ return this;
79
+ }
80
+ addTag(name, description = '', externalDocs) {
81
+ if (Array.isArray(name)) {
82
+ const arr = name;
83
+ for (const s of arr) {
84
+ this.document.tags.push({
85
+ name: s,
86
+ description: '',
87
+ });
88
+ }
89
+ return this;
90
+ }
91
+ this.document.tags.push({
92
+ name,
93
+ description,
94
+ externalDocs,
95
+ });
96
+ return this;
97
+ }
98
+ addSecurity(name, options) {
99
+ this.document.components.securitySchemes = {
100
+ ...(this.document.components.securitySchemes || {}),
101
+ [name]: options,
102
+ };
103
+ return this;
104
+ }
105
+ addSecurityRequirements(name, requirements = []) {
106
+ let securityRequirement;
107
+ if (typeof name === 'string') {
108
+ securityRequirement = { [name]: requirements };
109
+ }
110
+ else {
111
+ securityRequirement = name;
112
+ }
113
+ this.document.security = (this.document.security || []).concat({
114
+ ...securityRequirement,
115
+ });
116
+ return this;
117
+ }
118
+ addBearerAuth(options = {
119
+ type: 'http',
120
+ }, name = 'bearer') {
121
+ this.addSecurity(name, {
122
+ type: 'http',
123
+ scheme: 'bearer',
124
+ bearerFormat: 'JWT',
125
+ ...options,
126
+ });
127
+ return this;
128
+ }
129
+ addOAuth2(options = {
130
+ type: 'oauth2',
131
+ }, name = 'oauth2') {
132
+ if (!name) {
133
+ name = 'oauth2';
134
+ }
135
+ this.addSecurity(name, {
136
+ type: 'oauth2',
137
+ flows: {
138
+ ...options === null || options === void 0 ? void 0 : options.flows,
139
+ },
140
+ });
141
+ return this;
142
+ }
143
+ addApiKey(options = {
144
+ type: 'apiKey',
145
+ }, name = 'api_key') {
146
+ if (!name) {
147
+ name = 'api_key';
148
+ }
149
+ this.addSecurity(name, {
150
+ type: 'apiKey',
151
+ in: 'header',
152
+ name,
153
+ ...options,
154
+ });
155
+ return this;
156
+ }
157
+ addBasicAuth(options = {
158
+ type: 'http',
159
+ }, name = 'basic') {
160
+ if (!name) {
161
+ name = 'basic';
162
+ }
163
+ this.addSecurity(name, {
164
+ type: 'http',
165
+ scheme: 'basic',
166
+ ...options,
167
+ });
168
+ return this;
169
+ }
170
+ addCookieAuth(cookieName = 'connect.sid', options = {
171
+ type: 'apiKey',
172
+ }, securityName = 'cookie') {
173
+ if (!cookieName) {
174
+ cookieName = 'connect.sid';
175
+ }
176
+ if (!securityName) {
177
+ securityName = 'cookie';
178
+ }
179
+ this.addSecurity(securityName, {
180
+ type: 'apiKey',
181
+ in: 'cookie',
182
+ name: cookieName,
183
+ ...options,
184
+ });
185
+ return this;
186
+ }
187
+ build() {
188
+ return this.document;
189
+ }
190
+ }
191
+ exports.DocumentBuilder = DocumentBuilder;
192
+ //# sourceMappingURL=documentBuilder.js.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { AutoConfiguration as Configuration } from './configuration';
2
- export * from './controller/swagger';
3
- export * from './lib/createAPI';
4
- export * from './service/generator';
5
- export * from './interface';
1
+ export * from './decorators';
2
+ export * from './interfaces';
3
+ export { SwaggerConfiguration as Configuration } from './configuration';
4
+ export { SwaggerExplorer } from './swaggerExplorer';
5
+ export { SwaggerMiddleware } from './swaggerMiddleware';
6
6
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -10,11 +10,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.Configuration = void 0;
13
+ exports.SwaggerMiddleware = exports.SwaggerExplorer = exports.Configuration = void 0;
14
+ __exportStar(require("./decorators"), exports);
15
+ __exportStar(require("./interfaces"), exports);
14
16
  var configuration_1 = require("./configuration");
15
- Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.AutoConfiguration; } });
16
- __exportStar(require("./controller/swagger"), exports);
17
- __exportStar(require("./lib/createAPI"), exports);
18
- __exportStar(require("./service/generator"), exports);
19
- __exportStar(require("./interface"), exports);
17
+ Object.defineProperty(exports, "Configuration", { enumerable: true, get: function () { return configuration_1.SwaggerConfiguration; } });
18
+ var swaggerExplorer_1 = require("./swaggerExplorer");
19
+ Object.defineProperty(exports, "SwaggerExplorer", { enumerable: true, get: function () { return swaggerExplorer_1.SwaggerExplorer; } });
20
+ var swaggerMiddleware_1 = require("./swaggerMiddleware");
21
+ Object.defineProperty(exports, "SwaggerMiddleware", { enumerable: true, get: function () { return swaggerMiddleware_1.SwaggerMiddleware; } });
20
22
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,339 @@
1
+ /**
2
+ * inspired by https://github.com/metadevpro/openapi3-ts
3
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/3.0.0-rc0/versions/3.0.md
4
+ */
5
+ export interface OpenAPIObject {
6
+ openapi: string;
7
+ info: InfoObject;
8
+ servers?: ServerObject[];
9
+ paths: PathsObject;
10
+ components?: ComponentsObject;
11
+ security?: SecurityRequirementObject[];
12
+ tags?: TagObject[];
13
+ externalDocs?: ExternalDocumentationObject;
14
+ }
15
+ export interface InfoObject {
16
+ title: string;
17
+ description?: string;
18
+ termsOfService?: string;
19
+ contact?: ContactObject;
20
+ license?: LicenseObject;
21
+ version: string;
22
+ }
23
+ export interface ContactObject {
24
+ name?: string;
25
+ url?: string;
26
+ email?: string;
27
+ }
28
+ export interface LicenseObject {
29
+ name: string;
30
+ url?: string;
31
+ }
32
+ export interface ServerObject {
33
+ url: string;
34
+ description?: string;
35
+ variables?: Record<string, ServerVariableObject>;
36
+ }
37
+ export interface ServerVariableObject {
38
+ enum?: string[] | boolean[] | number[];
39
+ default: string | boolean | number;
40
+ description?: string;
41
+ }
42
+ export interface ComponentsObject {
43
+ schemas?: Record<string, SchemaObject | ReferenceObject>;
44
+ responses?: Record<string, ResponseObject | ReferenceObject>;
45
+ parameters?: Record<string, ParameterObject | ReferenceObject>;
46
+ examples?: Record<string, ExampleObject | ReferenceObject>;
47
+ requestBodies?: Record<string, RequestBodyObject | ReferenceObject>;
48
+ headers?: Record<string, HeaderObject | ReferenceObject>;
49
+ securitySchemes?: Record<string, SecuritySchemeObject | ReferenceObject>;
50
+ links?: Record<string, LinkObject | ReferenceObject>;
51
+ callbacks?: Record<string, CallbackObject | ReferenceObject>;
52
+ }
53
+ export declare type PathsObject = Record<string, PathItemObject>;
54
+ export interface PathItemObject {
55
+ $ref?: string;
56
+ summary?: string;
57
+ description?: string;
58
+ get?: OperationObject;
59
+ put?: OperationObject;
60
+ post?: OperationObject;
61
+ delete?: OperationObject;
62
+ options?: OperationObject;
63
+ head?: OperationObject;
64
+ patch?: OperationObject;
65
+ trace?: OperationObject;
66
+ servers?: ServerObject[];
67
+ parameters?: (ParameterObject | ReferenceObject)[];
68
+ }
69
+ export interface OperationObject {
70
+ tags?: string[];
71
+ summary?: string;
72
+ description?: string;
73
+ externalDocs?: ExternalDocumentationObject;
74
+ operationId?: string;
75
+ parameters?: (ParameterObject | ReferenceObject)[];
76
+ requestBody?: RequestBodyObject | ReferenceObject;
77
+ responses: ResponsesObject;
78
+ callbacks?: CallbacksObject;
79
+ deprecated?: boolean;
80
+ security?: SecurityRequirementObject[];
81
+ servers?: ServerObject[];
82
+ }
83
+ export interface ExternalDocumentationObject {
84
+ description?: string;
85
+ url: string;
86
+ }
87
+ export declare type ParameterLocation = 'query' | 'header' | 'path' | 'cookie';
88
+ export declare type ParameterStyle = 'matrix' | 'label' | 'form' | 'simple' | 'spaceDelimited' | 'pipeDelimited' | 'deepObject';
89
+ export interface BaseParameterObject {
90
+ description?: string;
91
+ required?: boolean;
92
+ deprecated?: boolean;
93
+ allowEmptyValue?: boolean;
94
+ style?: ParameterStyle;
95
+ explode?: boolean;
96
+ allowReserved?: boolean;
97
+ schema?: SchemaObject | ReferenceObject;
98
+ examples?: Record<string, ExampleObject | ReferenceObject>;
99
+ example?: any;
100
+ content?: ContentObject;
101
+ }
102
+ export interface ParameterObject extends BaseParameterObject {
103
+ name: string;
104
+ in: ParameterLocation;
105
+ }
106
+ export interface RequestBodyObject {
107
+ description?: string;
108
+ content: ContentObject;
109
+ required?: boolean;
110
+ }
111
+ export declare type ContentObject = Record<string, MediaTypeObject>;
112
+ export interface MediaTypeObject {
113
+ schema?: SchemaObject | ReferenceObject;
114
+ examples?: ExamplesObject;
115
+ example?: any;
116
+ encoding?: EncodingObject;
117
+ }
118
+ export declare type EncodingObject = Record<string, EncodingPropertyObject>;
119
+ export interface EncodingPropertyObject {
120
+ contentType?: string;
121
+ headers?: Record<string, HeaderObject | ReferenceObject>;
122
+ style?: string;
123
+ explode?: boolean;
124
+ allowReserved?: boolean;
125
+ }
126
+ export interface ResponsesObject extends Record<string, ResponseObject | ReferenceObject | undefined> {
127
+ default?: ResponseObject | ReferenceObject;
128
+ }
129
+ export interface ResponseObject {
130
+ description: string;
131
+ headers?: HeadersObject;
132
+ content?: ContentObject;
133
+ links?: LinksObject;
134
+ }
135
+ export declare type CallbacksObject = Record<string, CallbackObject | ReferenceObject>;
136
+ export declare type CallbackObject = Record<string, PathItemObject>;
137
+ export declare type HeadersObject = Record<string, HeaderObject | ReferenceObject>;
138
+ export interface ExampleObject {
139
+ summary?: string;
140
+ description?: string;
141
+ value?: any;
142
+ externalValue?: string;
143
+ }
144
+ export declare type LinksObject = Record<string, LinkObject | ReferenceObject>;
145
+ export interface LinkObject {
146
+ operationRef?: string;
147
+ operationId?: string;
148
+ parameters?: LinkParametersObject;
149
+ requestBody?: any | string;
150
+ description?: string;
151
+ server?: ServerObject;
152
+ }
153
+ export declare type LinkParametersObject = Record<string, any>;
154
+ export declare type HeaderObject = BaseParameterObject;
155
+ export interface TagObject {
156
+ name: string;
157
+ description?: string;
158
+ externalDocs?: ExternalDocumentationObject;
159
+ }
160
+ export declare type ExamplesObject = Record<string, ExampleObject | ReferenceObject>;
161
+ export interface ReferenceObject {
162
+ $ref: string;
163
+ }
164
+ export interface SchemaObject {
165
+ nullable?: boolean;
166
+ discriminator?: DiscriminatorObject;
167
+ readOnly?: boolean;
168
+ writeOnly?: boolean;
169
+ xml?: XmlObject;
170
+ externalDocs?: ExternalDocumentationObject;
171
+ example?: any;
172
+ examples?: any[] | Record<string, any>;
173
+ deprecated?: boolean;
174
+ type?: string;
175
+ allOf?: (SchemaObject | ReferenceObject)[];
176
+ oneOf?: (SchemaObject | ReferenceObject)[];
177
+ anyOf?: (SchemaObject | ReferenceObject)[];
178
+ not?: SchemaObject | ReferenceObject;
179
+ items?: SchemaObject | ReferenceObject;
180
+ properties?: Record<string, SchemaObject | ReferenceObject>;
181
+ additionalProperties?: SchemaObject | ReferenceObject | boolean;
182
+ patternProperties?: SchemaObject | ReferenceObject | any;
183
+ description?: string;
184
+ format?: string;
185
+ default?: any;
186
+ title?: string;
187
+ multipleOf?: number;
188
+ maximum?: number;
189
+ exclusiveMaximum?: boolean;
190
+ minimum?: number;
191
+ exclusiveMinimum?: boolean;
192
+ maxLength?: number;
193
+ minLength?: number;
194
+ pattern?: string;
195
+ maxItems?: number;
196
+ minItems?: number;
197
+ uniqueItems?: boolean;
198
+ maxProperties?: number;
199
+ minProperties?: number;
200
+ required?: string[];
201
+ enum?: any[];
202
+ }
203
+ export declare type SchemasObject = Record<string, SchemaObject>;
204
+ export interface DiscriminatorObject {
205
+ propertyName: string;
206
+ mapping?: Record<string, string>;
207
+ }
208
+ export interface XmlObject {
209
+ name?: string;
210
+ namespace?: string;
211
+ prefix?: string;
212
+ attribute?: boolean;
213
+ wrapped?: boolean;
214
+ }
215
+ export declare type SecuritySchemeType = 'apiKey' | 'http' | 'oauth2' | 'openIdConnect';
216
+ export interface SecuritySchemeObject {
217
+ type: SecuritySchemeType;
218
+ description?: string;
219
+ name?: string;
220
+ in?: string;
221
+ scheme?: string;
222
+ bearerFormat?: string;
223
+ flows?: OAuthFlowsObject;
224
+ openIdConnectUrl?: string;
225
+ }
226
+ export interface OAuthFlowsObject {
227
+ implicit?: OAuthFlowObject;
228
+ password?: OAuthFlowObject;
229
+ clientCredentials?: OAuthFlowObject;
230
+ authorizationCode?: OAuthFlowObject;
231
+ }
232
+ export interface OAuthFlowObject {
233
+ authorizationUrl?: string;
234
+ tokenUrl?: string;
235
+ refreshUrl?: string;
236
+ scopes: ScopesObject;
237
+ }
238
+ export declare type ScopesObject = Record<string, any>;
239
+ export declare type SecurityRequirementObject = Record<string, string[]>;
240
+ /**
241
+ * 非 open api spec
242
+ */
243
+ export declare type SwaggerEnumType = string[] | number[] | (string | number)[] | Record<number, string>;
244
+ export interface Type<T = any> extends Function {
245
+ new (...args: any[]): T;
246
+ }
247
+ export interface SchemaObjectMetadata extends Omit<SchemaObject, 'type' | 'required'> {
248
+ type?: Type<unknown> | [Type] | string | Record<string, any>;
249
+ isArray?: boolean;
250
+ required?: boolean;
251
+ name?: string;
252
+ enumName?: string;
253
+ }
254
+ export declare type AuthType = 'basic' | 'bearer' | 'cookie' | 'oauth2' | 'apikey' | 'custom';
255
+ /**
256
+ * 继承自 https://swagger.io/specification/#security-scheme-object
257
+ */
258
+ export interface AuthOptions extends Omit<SecuritySchemeObject, 'type'> {
259
+ /**
260
+ * 验权类型
261
+ * basic => http basic 验证
262
+ * bearer => http jwt 验证
263
+ * cookie => cookie 方式验证
264
+ * oauth2 => 使用 oauth2
265
+ * apikey => apiKey
266
+ * custom => 自定义方式
267
+ */
268
+ authType: AuthType;
269
+ /**
270
+ * https://swagger.io/specification/#security-scheme-object type 字段
271
+ */
272
+ type?: SecuritySchemeType;
273
+ /**
274
+ * authType = cookie 时可以修改,通过 ApiCookie 装饰器关联的名称
275
+ */
276
+ securityName?: string;
277
+ /**
278
+ * authType = cookie 时可以修改,cookie 的名称
279
+ */
280
+ cookieName?: string;
281
+ }
282
+ /**
283
+ * see https://swagger.io/specification/
284
+ */
285
+ export interface SwaggerOptions {
286
+ /**
287
+ * 默认值: My Project
288
+ * https://swagger.io/specification/#info-object title 字段
289
+ */
290
+ title?: string;
291
+ /**
292
+ * 默认值: This is a swagger-ui for midwayjs project
293
+ * https://swagger.io/specification/#info-object description 字段
294
+ */
295
+ description?: string;
296
+ /**
297
+ * 默认值: 1.0.0
298
+ * https://swagger.io/specification/#info-object version 字段
299
+ */
300
+ version?: string;
301
+ /**
302
+ * https://swagger.io/specification/#info-object contact 字段
303
+ */
304
+ contact?: ContactObject;
305
+ /**
306
+ * https://swagger.io/specification/#info-object license 字段
307
+ */
308
+ license?: LicenseObject;
309
+ /**
310
+ * https://swagger.io/specification/#info-object termsOfService 字段
311
+ */
312
+ termsOfService?: string;
313
+ /**
314
+ * https://swagger.io/specification/#openapi-object externalDocs 字段
315
+ */
316
+ externalDocs?: ExternalDocumentationObject;
317
+ /**
318
+ * https://swagger.io/specification/#openapi-object servers 字段
319
+ */
320
+ servers?: Array<ServerObject>;
321
+ /**
322
+ * https://swagger.io/specification/#openapi-object tags 字段
323
+ */
324
+ tags?: Array<TagObject>;
325
+ /**
326
+ * 可以参考 https://swagger.io/specification/#security-scheme-object
327
+ */
328
+ auth?: AuthOptions | AuthOptions[];
329
+ /**
330
+ * api 的 根路径
331
+ */
332
+ basePath?: string | string[];
333
+ /**
334
+ * 默认值: /swagger-ui
335
+ * 访问 swagger ui 的路径
336
+ */
337
+ swaggerPath?: string;
338
+ }
339
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * inspired by https://github.com/metadevpro/openapi3-ts
4
+ * @see https://github.com/OAI/OpenAPI-Specification/blob/3.0.0-rc0/versions/3.0.md
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,30 @@
1
+ export declare class SwaggerExplorer {
2
+ private swaggerConfig;
3
+ private documentBuilder;
4
+ init(): Promise<void>;
5
+ scanApp(): void;
6
+ getData(): Omit<import("./interfaces").OpenAPIObject, "paths">;
7
+ private generatePath;
8
+ /**
9
+ * 构造 router 提取方法
10
+ */
11
+ private generateRouteMethod;
12
+ /**
13
+ * 提取参数
14
+ * @param params
15
+ * @param p
16
+ */
17
+ private parseFromParamsToP;
18
+ /**
19
+ * 解析类型的 ApiProperty
20
+ * @param clzz
21
+ */
22
+ private parseClzz;
23
+ /**
24
+ * 授权验证
25
+ * @param opts
26
+ * @returns
27
+ */
28
+ private setAuth;
29
+ }
30
+ //# sourceMappingURL=swaggerExplorer.d.ts.map