@trapi/swagger 0.3.4 → 0.3.6

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 (41) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +0 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/specification/v2/index.d.ts +2 -23
  6. package/dist/specification/v2/index.d.ts.map +1 -1
  7. package/dist/specification/v2/index.js +17 -383
  8. package/dist/specification/v2/index.js.map +1 -1
  9. package/dist/specification/v2/module.d.ts +24 -0
  10. package/dist/specification/v2/module.d.ts.map +1 -0
  11. package/dist/specification/v2/module.js +389 -0
  12. package/dist/specification/v2/module.js.map +1 -0
  13. package/dist/specification/v3/index.d.ts +2 -24
  14. package/dist/specification/v3/index.d.ts.map +1 -1
  15. package/dist/specification/v3/index.js +17 -369
  16. package/dist/specification/v3/index.js.map +1 -1
  17. package/dist/specification/v3/module.d.ts +25 -0
  18. package/dist/specification/v3/module.d.ts.map +1 -0
  19. package/dist/specification/v3/module.js +377 -0
  20. package/dist/specification/v3/module.js.map +1 -0
  21. package/dist/utils/index.d.ts +0 -1
  22. package/dist/utils/index.d.ts.map +1 -1
  23. package/dist/utils/index.js +0 -1
  24. package/dist/utils/index.js.map +1 -1
  25. package/package.json +11 -13
  26. package/dist/config/index.d.ts +0 -2
  27. package/dist/config/index.d.ts.map +0 -1
  28. package/dist/config/index.js +0 -24
  29. package/dist/config/index.js.map +0 -1
  30. package/dist/config/utils/index.d.ts +0 -2
  31. package/dist/config/utils/index.d.ts.map +0 -1
  32. package/dist/config/utils/index.js +0 -24
  33. package/dist/config/utils/index.js.map +0 -1
  34. package/dist/config/utils/validator.d.ts +0 -5
  35. package/dist/config/utils/validator.d.ts.map +0 -1
  36. package/dist/config/utils/validator.js +0 -85
  37. package/dist/config/utils/validator.js.map +0 -1
  38. package/dist/utils/yup.d.ts +0 -5
  39. package/dist/utils/yup.d.ts.map +0 -1
  40. package/dist/utils/yup.js +0 -17
  41. package/dist/utils/yup.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './config';
2
1
  export * from './metadata';
3
2
  export * from './module';
4
3
  export * from './specification';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,cAAc,YAAY,CAAC;AAC3B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -20,7 +20,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
20
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- __exportStar(require("./config"), exports);
24
23
  __exportStar(require("./metadata"), exports);
25
24
  __exportStar(require("./module"), exports);
26
25
  __exportStar(require("./specification"), exports);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,6CAA2B;AAC3B,2CAAyB;AACzB,kDAAgC;AAChC,yCAAuB;AACvB,0CAAwB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,6CAA2B;AAC3B,2CAAyB;AACzB,kDAAgC;AAChC,yCAAuB;AACvB,0CAAwB"}
@@ -1,24 +1,3 @@
1
- import { EnumType, IntersectionType, ReferenceType, ResolverProperty } from '@trapi/decorator';
2
- import { SpecificationV2 } from './type';
3
- import { AbstractSpecGenerator } from '../abstract';
4
- export declare class Version2SpecGenerator extends AbstractSpecGenerator<SpecificationV2.Spec, SpecificationV2.Schema> {
5
- getSwaggerSpec(): SpecificationV2.Spec;
6
- build(): SpecificationV2.Spec;
7
- private static translateSecurityDefinitions;
8
- private buildDefinitions;
9
- private decideEnumType;
10
- private buildPaths;
11
- private buildPathMethod;
12
- private buildParameter;
13
- private handleMethodConsumes;
14
- private hasFormParams;
15
- private supportsBodyParameters;
16
- protected getSwaggerTypeForEnumType(enumType: EnumType): SpecificationV2.Schema;
17
- protected getSwaggerTypeForIntersectionType(type: IntersectionType): SpecificationV2.Schema;
18
- protected getSwaggerTypeForReferenceType(referenceType: ReferenceType): SpecificationV2.Schema;
19
- protected buildProperties(properties: ResolverProperty[]): Record<string, SpecificationV2.Schema>;
20
- private buildOperation;
21
- private getMimeType;
22
- private handleMethodProduces;
23
- }
1
+ export * from './module';
2
+ export * from './type';
24
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/specification/v2/index.ts"],"names":[],"mappings":"AAOA,OAAO,EACH,QAAQ,EAAE,gBAAgB,EAE1B,aAAa,EACb,gBAAgB,EAGnB,MAAM,kBAAkB,CAAC;AAY1B,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,qBAAa,qBAAsB,SAAQ,qBAAqB,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC;IACnG,cAAc,IAAI,eAAe,CAAC,IAAI;IAItC,KAAK,IAAK,eAAe,CAAC,IAAI;IA0CrC,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAoE3C,OAAO,CAAC,gBAAgB;IA8DxB,OAAO,CAAC,cAAc;IA0BtB,OAAO,CAAC,UAAU;IAsBlB,OAAO,CAAC,eAAe;IA+CvB,OAAO,CAAC,cAAc;IAgCtB,OAAO,CAAC,oBAAoB;IAiB5B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,sBAAsB;IAQ9B,SAAS,CAAC,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,GAAI,eAAe,CAAC,MAAM;IAYhF,SAAS,CAAC,iCAAiC,CAAC,IAAI,EAAE,gBAAgB,GAAI,eAAe,CAAC,MAAM;IAqB5F,SAAS,CAAC,8BAA8B,CAAC,aAAa,EAAE,aAAa,GAAG,eAAe,CAAC,MAAM;IAI9F,SAAS,CAAC,eAAe,CAAC,UAAU,EAAE,gBAAgB,EAAE,GAAI,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;IAclG,OAAO,CAAC,cAAc;IA4BtB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,oBAAoB;CAO/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/specification/v2/index.ts"],"names":[],"mappings":"AAOA,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC"}
@@ -1,391 +1,25 @@
1
1
  "use strict";
2
2
  /*
3
- * Copyright (c) 2021.
3
+ * Copyright (c) 2022.
4
4
  * Author Peter Placzek (tada5hi)
5
5
  * For the full copyright and license information,
6
6
  * view the LICENSE file that was distributed with this source code.
7
7
  */
8
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
9
+ if (k2 === undefined) k2 = k;
10
+ var desc = Object.getOwnPropertyDescriptor(m, k);
11
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
12
+ desc = { enumerable: true, get: function() { return m[k]; } };
13
+ }
14
+ Object.defineProperty(o, k2, desc);
15
+ }) : (function(o, m, k, k2) {
16
+ if (k2 === undefined) k2 = k;
17
+ o[k2] = m[k];
18
+ }));
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
8
22
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.Version2SpecGenerator = void 0;
10
- const decorator_1 = require("@trapi/decorator");
11
- const lodash_1 = require("lodash");
12
- const merge_1 = require("merge");
13
- const path_1 = require("path");
14
- const url_1 = require("url");
15
- const utils_1 = require("../../utils");
16
- const abstract_1 = require("../abstract");
17
- class Version2SpecGenerator extends abstract_1.AbstractSpecGenerator {
18
- getSwaggerSpec() {
19
- return this.build();
20
- }
21
- build() {
22
- if (typeof this.spec !== 'undefined') {
23
- return this.spec;
24
- }
25
- let spec = {
26
- basePath: this.config.basePath,
27
- definitions: this.buildDefinitions(),
28
- info: this.buildInfo(),
29
- paths: this.buildPaths(),
30
- swagger: '2.0',
31
- };
32
- spec.securityDefinitions = this.config.securityDefinitions ?
33
- Version2SpecGenerator.translateSecurityDefinitions(this.config.securityDefinitions) :
34
- {};
35
- if (this.config.consumes) {
36
- spec.consumes = this.config.consumes;
37
- }
38
- if (this.config.produces) {
39
- spec.produces = this.config.produces;
40
- }
41
- if (this.config.host) {
42
- const url = new url_1.URL(this.config.host);
43
- let host = (url.host + url.pathname).replace(/([^:]\/)\/+/g, '$1');
44
- host = host.substr(-1, 1) === '/' ? host.substr(0, host.length - 1) : host;
45
- spec.host = host;
46
- }
47
- if (this.config.specificationExtra) {
48
- spec = (0, merge_1.recursive)(spec, this.config.specificationExtra);
49
- }
50
- this.spec = spec;
51
- return spec;
52
- }
53
- static translateSecurityDefinitions(securityDefinitions) {
54
- const definitions = {};
55
- // tslint:disable-next-line:forin
56
- const keys = Object.keys(securityDefinitions);
57
- for (let i = 0; i < keys.length; i++) {
58
- const securityDefinition = securityDefinitions[keys[i]];
59
- switch (securityDefinition.type) {
60
- case 'http':
61
- if (securityDefinition.schema === 'basic') {
62
- definitions[keys[i]] = {
63
- type: 'basic',
64
- };
65
- }
66
- break;
67
- case 'apiKey':
68
- definitions[keys[i]] = securityDefinition;
69
- break;
70
- case 'oauth2':
71
- if (securityDefinition.flows.implicit) {
72
- definitions[`${keys[i]}Implicit`] = {
73
- type: 'oauth2',
74
- flow: 'implicit',
75
- authorizationUrl: securityDefinition.flows.implicit.authorizationUrl,
76
- scopes: securityDefinition.flows.implicit.scopes,
77
- };
78
- }
79
- if (securityDefinition.flows.password) {
80
- definitions[`${keys[i]}Implicit`] = {
81
- type: 'oauth2',
82
- flow: 'password',
83
- tokenUrl: securityDefinition.flows.password.tokenUrl,
84
- scopes: securityDefinition.flows.password.scopes,
85
- };
86
- }
87
- if (securityDefinition.flows.authorizationCode) {
88
- definitions[`${keys[i]}AccessCode`] = {
89
- type: 'oauth2',
90
- flow: 'accessCode',
91
- tokenUrl: securityDefinition.flows.authorizationCode.tokenUrl,
92
- authorizationUrl: securityDefinition.flows.authorizationCode.authorizationUrl,
93
- scopes: securityDefinition.flows.authorizationCode.scopes,
94
- };
95
- }
96
- if (securityDefinition.flows.clientCredentials) {
97
- definitions[`${keys[i]}Application`] = {
98
- type: 'oauth2',
99
- flow: 'application',
100
- tokenUrl: securityDefinition.flows.clientCredentials.tokenUrl,
101
- scopes: securityDefinition.flows.clientCredentials.scopes,
102
- };
103
- }
104
- break;
105
- }
106
- }
107
- return definitions;
108
- }
109
- /*
110
- Definitions ( + utils)
111
- */
112
- buildDefinitions() {
113
- const definitions = {};
114
- Object.keys(this.metadata.referenceTypes).map((typeName) => {
115
- const referenceType = this.metadata.referenceTypes[typeName];
116
- // const key : string = referenceType.typeName.replace('_', '');
117
- if ((0, decorator_1.isRefObjectType)(referenceType)) {
118
- const required = referenceType.properties
119
- .filter((p) => p.required).map((p) => p.name);
120
- definitions[referenceType.refName] = {
121
- description: referenceType.description,
122
- properties: this.buildProperties(referenceType.properties),
123
- required: required && required.length > 0 ? Array.from(new Set(required)) : undefined,
124
- type: 'object',
125
- };
126
- if (referenceType.additionalProperties) {
127
- definitions[referenceType.refName].additionalProperties = true;
128
- }
129
- if (referenceType.example) {
130
- definitions[referenceType.refName].example = referenceType.example;
131
- }
132
- }
133
- else if ((0, decorator_1.isRefEnumType)(referenceType)) {
134
- definitions[referenceType.refName] = {
135
- description: referenceType.description,
136
- enum: referenceType.members,
137
- type: this.decideEnumType(referenceType.members, referenceType.refName),
138
- };
139
- if (referenceType.memberNames !== undefined && referenceType.members.length === referenceType.memberNames.length) {
140
- definitions[referenceType.refName]['x-enum-varnames'] = referenceType.memberNames;
141
- }
142
- }
143
- else if ((0, decorator_1.isRefAliasType)(referenceType)) {
144
- const swaggerType = this.getSwaggerType(referenceType.type);
145
- const format = referenceType.format;
146
- const validators = Object.keys(referenceType.validators)
147
- .filter((key) => !key.startsWith('is') && key !== 'minDate' && key !== 'maxDate')
148
- .reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: referenceType.validators[key].value })), {});
149
- definitions[referenceType.refName] = Object.assign(Object.assign(Object.assign({}, swaggerType), { default: referenceType.default || swaggerType.default, example: referenceType.example, format: format || swaggerType.format, description: referenceType.description }), validators);
150
- }
151
- else {
152
- console.log(referenceType);
153
- }
154
- return typeName;
155
- });
156
- return definitions;
157
- }
158
- decideEnumType(anEnum, nameOfEnum) {
159
- const typesUsedInEnum = this.determineTypesUsedInEnum(anEnum);
160
- const badEnumErrorMessage = () => {
161
- const valuesDelimited = Array.from(typesUsedInEnum).join(',');
162
- return `Enums can only have string or number values, but enum ${nameOfEnum} had ${valuesDelimited}`;
163
- };
164
- let enumTypeForSwagger = 'string';
165
- if (typesUsedInEnum.has('string') && typesUsedInEnum.size === 1) {
166
- enumTypeForSwagger = 'string';
167
- }
168
- else if (typesUsedInEnum.has('number') && typesUsedInEnum.size === 1) {
169
- enumTypeForSwagger = 'number';
170
- }
171
- else if (typesUsedInEnum.size === 2 && typesUsedInEnum.has('number') && typesUsedInEnum.has('string')) {
172
- enumTypeForSwagger = 'string';
173
- }
174
- else {
175
- throw new Error(badEnumErrorMessage());
176
- }
177
- return enumTypeForSwagger;
178
- }
179
- /*
180
- Path & Parameter ( + utils)
181
- */
182
- buildPaths() {
183
- const paths = {};
184
- this.metadata.controllers.forEach((controller) => {
185
- controller.methods.forEach((method) => {
186
- let fullPath = path_1.posix.join('/', (controller.path ? controller.path : ''), method.path);
187
- fullPath = (0, utils_1.normalizePathParameters)(fullPath);
188
- paths[fullPath] = paths[fullPath] || {};
189
- method.consumes = (0, lodash_1.union)(controller.consumes, method.consumes);
190
- method.produces = (0, lodash_1.union)(controller.produces, method.produces);
191
- method.tags = (0, lodash_1.union)(controller.tags, method.tags);
192
- method.security = method.security || controller.security;
193
- method.responses = (0, lodash_1.union)(controller.responses, method.responses);
194
- const pathObject = paths[fullPath];
195
- pathObject[method.method] = this.buildPathMethod(controller.name, method);
196
- });
197
- });
198
- return paths;
199
- }
200
- buildPathMethod(controllerName, method) {
201
- const pathMethod = this.buildOperation(method);
202
- pathMethod.description = method.description;
203
- if (method.summary) {
204
- pathMethod.summary = method.summary;
205
- }
206
- if (method.deprecated) {
207
- pathMethod.deprecated = method.deprecated;
208
- }
209
- if (method.tags.length) {
210
- pathMethod.tags = method.tags;
211
- }
212
- if (method.security) {
213
- pathMethod.security = method.security.map((s) => ({
214
- [s.name]: s.scopes || [],
215
- }));
216
- }
217
- this.handleMethodConsumes(method, pathMethod);
218
- pathMethod.parameters = method.parameters
219
- .filter((p) => (p.in !== 'param'))
220
- .map((p) => this.buildParameter(p));
221
- method.parameters
222
- .filter((p) => (p.in === 'param'))
223
- .forEach((p) => {
224
- pathMethod.parameters.push(this.buildParameter({
225
- description: p.description,
226
- in: 'query',
227
- name: p.name,
228
- parameterName: p.parameterName,
229
- required: false,
230
- type: p.type,
231
- }));
232
- pathMethod.parameters.push(this.buildParameter({
233
- description: p.description,
234
- in: 'formData',
235
- name: p.name,
236
- parameterName: p.parameterName,
237
- required: false,
238
- type: p.type,
239
- }));
240
- });
241
- if (pathMethod.parameters.filter((p) => p.in === 'body').length > 1) {
242
- throw new Error('Only one body parameter allowed per controller method.');
243
- }
244
- return pathMethod;
245
- }
246
- buildParameter(parameter) {
247
- const swaggerParameter = {
248
- description: parameter.description,
249
- in: parameter.in,
250
- name: parameter.name,
251
- required: parameter.required,
252
- };
253
- const parameterType = this.getSwaggerType(parameter.type);
254
- if (((0, utils_1.hasOwnProperty)(parameterType, '$ref') && parameterType.$ref) || parameter.in === 'body') {
255
- swaggerParameter.schema = parameterType;
256
- }
257
- else {
258
- swaggerParameter.type = parameterType.type;
259
- if (parameterType.items) {
260
- swaggerParameter.items = parameterType.items;
261
- if (parameter.collectionFormat || this.config.collectionFormat) {
262
- swaggerParameter.collectionFormat = parameter.collectionFormat || this.config.collectionFormat;
263
- }
264
- }
265
- }
266
- if (parameterType.format) {
267
- swaggerParameter.format = parameterType.format;
268
- }
269
- if (parameter.default !== undefined) {
270
- swaggerParameter.default = parameter.default;
271
- }
272
- if (parameterType.enum) {
273
- swaggerParameter.enum = parameterType.enum;
274
- }
275
- return swaggerParameter;
276
- }
277
- handleMethodConsumes(method, pathMethod) {
278
- if (method.consumes.length) {
279
- pathMethod.consumes = method.consumes;
280
- }
281
- if ((!pathMethod.consumes || !pathMethod.consumes.length)) {
282
- if (method.parameters.some((p) => (p.in === 'formData' && p.type.typeName === 'file'))) {
283
- pathMethod.consumes = pathMethod.consumes || [];
284
- pathMethod.consumes.push('multipart/form-data');
285
- }
286
- else if (this.hasFormParams(method)) {
287
- pathMethod.consumes = pathMethod.consumes || [];
288
- pathMethod.consumes.push('application/x-www-form-urlencoded');
289
- }
290
- else if (this.supportsBodyParameters(method.method)) {
291
- pathMethod.consumes = pathMethod.consumes || [];
292
- pathMethod.consumes.push('application/json');
293
- }
294
- }
295
- }
296
- hasFormParams(method) {
297
- return method.parameters.find((p) => (p.in === 'formData'));
298
- }
299
- supportsBodyParameters(method) {
300
- return ['post', 'put', 'patch'].some((m) => m === method);
301
- }
302
- /*
303
- Swagger Type ( + utils)
304
- */
305
- getSwaggerTypeForEnumType(enumType) {
306
- const types = this.determineTypesUsedInEnum(enumType.members);
307
- if (types.size === 1) {
308
- const type = types.values().next().value;
309
- const nullable = !!enumType.members.includes(null);
310
- return { type, enum: enumType.members.map((member) => (member === null ? null : String(member))), 'x-nullable': nullable };
311
- }
312
- const valuesDelimited = Array.from(types).join(',');
313
- throw new Error(`Enums can only have string or number values, but enum had ${valuesDelimited}`);
314
- }
315
- getSwaggerTypeForIntersectionType(type) {
316
- // tslint:disable-next-line:no-shadowed-variable
317
- const properties = type.members.reduce((acc, type) => {
318
- if (type.typeName === 'refObject') {
319
- let refType = type;
320
- refType = this.metadata.referenceTypes[refType.refName];
321
- const props = refType &&
322
- refType.properties &&
323
- refType.properties.reduce((pAcc, prop) => (Object.assign(Object.assign({}, pAcc), { [prop.name]: this.getSwaggerType(prop.type) })), {});
324
- return Object.assign(Object.assign({}, acc), props);
325
- }
326
- return Object.assign({}, acc);
327
- }, {});
328
- return { type: 'object', properties };
329
- }
330
- getSwaggerTypeForReferenceType(referenceType) {
331
- return { $ref: `#/definitions/${referenceType.refName}` };
332
- }
333
- buildProperties(properties) {
334
- const swaggerProperties = {};
335
- properties.forEach((property) => {
336
- const swaggerType = this.getSwaggerType(property.type);
337
- if (!(0, utils_1.hasOwnProperty)(swaggerType, '$ref') || !swaggerType.$ref) {
338
- swaggerType.description = property.description;
339
- }
340
- swaggerProperties[property.name] = swaggerType;
341
- });
342
- return swaggerProperties;
343
- }
344
- buildOperation(method) {
345
- const operation = {
346
- operationId: this.getOperationId(method.name),
347
- produces: [],
348
- responses: {},
349
- };
350
- const methodReturnTypes = new Set();
351
- method.responses.forEach((res) => {
352
- operation.responses[res.status] = {
353
- description: res.description,
354
- };
355
- if (res.schema) {
356
- const swaggerType = this.getSwaggerType(res.schema);
357
- if (swaggerType.type !== 'void') {
358
- operation.responses[res.status].schema = swaggerType;
359
- }
360
- methodReturnTypes.add(this.getMimeType(swaggerType));
361
- }
362
- if (res.examples) {
363
- operation.responses[res.status].examples = { 'application/json': res.examples };
364
- }
365
- });
366
- this.handleMethodProduces(method, operation, methodReturnTypes);
367
- return operation;
368
- }
369
- getMimeType(swaggerType) {
370
- if (swaggerType.$ref ||
371
- swaggerType.type === 'array' ||
372
- swaggerType.type === 'object') {
373
- return 'application/json';
374
- }
375
- if (swaggerType.type === 'string' &&
376
- swaggerType.format === 'binary') {
377
- return 'application/octet-stream';
378
- }
379
- return 'text/html';
380
- }
381
- handleMethodProduces(method, operation, methodReturnTypes) {
382
- if (method.produces.length) {
383
- operation.produces = method.produces;
384
- }
385
- else if (methodReturnTypes && methodReturnTypes.size > 0) {
386
- operation.produces = Array.from(methodReturnTypes);
387
- }
388
- }
389
- }
390
- exports.Version2SpecGenerator = Version2SpecGenerator;
23
+ __exportStar(require("./module"), exports);
24
+ __exportStar(require("./type"), exports);
391
25
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/specification/v2/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,gDAO0B;AAC1B,mCAA+B;AAC/B,iCAAkC;AAClC,+BAA6B;AAC7B,6BAA0B;AAK1B,uCAAsE;AAItE,0CAAoD;AAEpD,MAAa,qBAAsB,SAAQ,gCAAmE;IACnG,cAAc;QACjB,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEM,KAAK;QACR,IAAI,OAAO,IAAI,CAAC,IAAI,KAAK,WAAW,EAAE;YAClC,OAAO,IAAI,CAAC,IAAI,CAAC;SACpB;QAED,IAAI,IAAI,GAAyB;YAC7B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,WAAW,EAAE,IAAI,CAAC,gBAAgB,EAAE;YACpC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE;YACtB,KAAK,EAAE,IAAI,CAAC,UAAU,EAAE;YACxB,OAAO,EAAE,KAAK;SACjB,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AK,QAAQ,EAC/B;YACE,OAAO,kBAAkB,CAAC;SAC7B;QAAC,IACE,WAAW,CAAC,IAAI,KAAK,QAAQ;YAC7B,WAAW,CAAC,MAAM,KAAK,QAAQ,EACjC;YACE,OAAO,0BAA0B,CAAC;SACrC;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IAEO,oBAAoB,CAAC,MAAc,EAAE,SAAc,EAAE,iBAA8B;QACvF,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE;YACxB,SAAS,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;SACxC;aAAM,IAAI,iBAAiB,IAAI,iBAAiB,CAAC,IAAI,GAAG,CAAC,EAAE;YACxD,SAAS,CAAC,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;SACtD;IACL,CAAC;CACJ;AAnbD,sDAmbC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/specification/v2/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,2CAAyB;AACzB,yCAAuB"}
@@ -0,0 +1,24 @@
1
+ import { EnumType, IntersectionType, ReferenceType, ResolverProperty } from '@trapi/decorator';
2
+ import { SpecificationV2 } from './type';
3
+ import { AbstractSpecGenerator } from '../abstract';
4
+ export declare class Version2SpecGenerator extends AbstractSpecGenerator<SpecificationV2.Spec, SpecificationV2.Schema> {
5
+ getSwaggerSpec(): SpecificationV2.Spec;
6
+ build(): SpecificationV2.Spec;
7
+ private static translateSecurityDefinitions;
8
+ private buildDefinitions;
9
+ private decideEnumType;
10
+ private buildPaths;
11
+ private buildPathMethod;
12
+ private buildParameter;
13
+ private handleMethodConsumes;
14
+ private hasFormParams;
15
+ private supportsBodyParameters;
16
+ protected getSwaggerTypeForEnumType(enumType: EnumType): SpecificationV2.Schema;
17
+ protected getSwaggerTypeForIntersectionType(type: IntersectionType): SpecificationV2.Schema;
18
+ protected getSwaggerTypeForReferenceType(referenceType: ReferenceType): SpecificationV2.Schema;
19
+ protected buildProperties(properties: ResolverProperty[]): Record<string, SpecificationV2.Schema>;
20
+ private buildOperation;
21
+ private getMimeType;
22
+ private handleMethodProduces;
23
+ }
24
+ //# sourceMappingURL=module.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../../src/specification/v2/module.ts"],"names":[],"mappings":"AAOA,OAAO,EACH,QAAQ,EAAE,gBAAgB,EAE1B,aAAa,EACb,gBAAgB,EAGnB,MAAM,kBAAkB,CAAC;AAW1B,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAEpD,qBAAa,qBAAsB,SAAQ,qBAAqB,CAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,MAAM,CAAC;IACnG,cAAc,IAAI,eAAe,CAAC,IAAI;IAItC,KAAK,IAAK,eAAe,CAAC,IAAI;IA0CrC,OAAO,CAAC,MAAM,CAAC,4BAA4B;IAoE3C,OAAO,CAAC,gBAAgB;IA4DxB,OAAO,CAAC,cAAc;IA0BtB,OAAO,CAAC,UAAU;IAyBlB,OAAO,CAAC,eAAe;IA+CvB,OAAO,CAAC,cAAc;IAgCtB,OAAO,CAAC,oBAAoB;IAiB5B,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,sBAAsB;IAQ9B,SAAS,CAAC,yBAAyB,CAAC,QAAQ,EAAE,QAAQ,GAAI,eAAe,CAAC,MAAM;IAYhF,SAAS,CAAC,iCAAiC,CAAC,IAAI,EAAE,gBAAgB,GAAI,eAAe,CAAC,MAAM;IAqB5F,SAAS,CAAC,8BAA8B,CAAC,aAAa,EAAE,aAAa,GAAG,eAAe,CAAC,MAAM;IAI9F,SAAS,CAAC,eAAe,CAAC,UAAU,EAAE,gBAAgB,EAAE,GAAI,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;IAclG,OAAO,CAAC,cAAc;IA4BtB,OAAO,CAAC,WAAW;IAgBnB,OAAO,CAAC,oBAAoB;CAO/B"}