@tsoa-next/cli 7.2.1 → 7.3.2
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/README.MD +3 -3
- package/dist/cli.js +63 -7
- package/dist/cli.js.map +1 -1
- package/dist/metadataGeneration/metadataGenerator.js +2 -0
- package/dist/metadataGeneration/metadataGenerator.js.map +1 -1
- package/dist/metadataGeneration/parameterGenerator.d.ts +3 -0
- package/dist/metadataGeneration/parameterGenerator.js +49 -2
- package/dist/metadataGeneration/parameterGenerator.js.map +1 -1
- package/dist/metadataGeneration/typeResolver.d.ts +8 -0
- package/dist/metadataGeneration/typeResolver.js +222 -19
- package/dist/metadataGeneration/typeResolver.js.map +1 -1
- package/dist/routeGeneration/routeGenerator.js +3 -0
- package/dist/routeGeneration/routeGenerator.js.map +1 -1
- package/dist/routeGeneration/templates/express.hbs +17 -32
- package/dist/routeGeneration/templates/hapi.hbs +25 -22
- package/dist/routeGeneration/templates/koa.hbs +21 -21
- package/dist/swagger/specGenerator.d.ts +4 -0
- package/dist/swagger/specGenerator.js +20 -0
- package/dist/swagger/specGenerator.js.map +1 -1
- package/dist/swagger/specGenerator2.js +9 -6
- package/dist/swagger/specGenerator2.js.map +1 -1
- package/dist/swagger/specGenerator3.d.ts +1 -0
- package/dist/swagger/specGenerator3.js +30 -15
- package/dist/swagger/specGenerator3.js.map +1 -1
- package/dist/utils/decoratorUtils.js +1 -0
- package/dist/utils/decoratorUtils.js.map +1 -1
- package/dist/utils/validateDecoratorUtils.d.ts +9 -0
- package/dist/utils/validateDecoratorUtils.js +225 -0
- package/dist/utils/validateDecoratorUtils.js.map +1 -0
- package/package.json +7 -6
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/
|
|
4
|
-
import type { TsoaRoute } from '@tsoa-next/runtime';
|
|
3
|
+
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/tsoa-next/tsoa-next
|
|
4
|
+
import type { AdditionalProps, Tsoa, TsoaRoute } from '@tsoa-next/runtime';
|
|
5
5
|
import { fetchMiddlewares, ExpressTemplateService } from '@tsoa-next/runtime';
|
|
6
6
|
{{#each controllers}}
|
|
7
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
8
7
|
import { {{name}} } from '{{modulePath}}';
|
|
9
8
|
{{/each}}
|
|
10
9
|
{{#if authenticationModule}}
|
|
@@ -29,9 +28,6 @@ const multer = require('multer');
|
|
|
29
28
|
const expressAuthenticationRecasted = expressAuthentication as (req: ExRequest, securityName: string, scopes?: string[], res?: ExResponse) => Promise<any>;
|
|
30
29
|
{{/if}}
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
34
|
-
|
|
35
31
|
const models: TsoaRoute.Models = {
|
|
36
32
|
{{#each models}}
|
|
37
33
|
"{{@key}}": {
|
|
@@ -53,32 +49,30 @@ const models: TsoaRoute.Models = {
|
|
|
53
49
|
"type": {{{json type}}},
|
|
54
50
|
{{/if}}
|
|
55
51
|
},
|
|
56
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
57
52
|
{{/each}}
|
|
58
53
|
};
|
|
59
|
-
const templateService = new ExpressTemplateService(models, {{{ json minimalSwaggerConfig}}});
|
|
60
|
-
|
|
61
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
54
|
|
|
66
55
|
{{#if useFileUploads}}
|
|
67
|
-
export function RegisterRoutes(app: Router,opts?:{multer?:ReturnType<typeof multer
|
|
56
|
+
export function RegisterRoutes(app: Router,opts?:{multer?:ReturnType<typeof multer>; validation?: Tsoa.ValidationContext}) {
|
|
68
57
|
{{else}}
|
|
69
|
-
export function RegisterRoutes(app: Router) {
|
|
58
|
+
export function RegisterRoutes(app: Router,opts?:{validation?: Tsoa.ValidationContext}) {
|
|
70
59
|
{{/if}}
|
|
71
60
|
|
|
72
61
|
// ###########################################################################################################
|
|
73
62
|
// NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look
|
|
74
|
-
// Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/
|
|
63
|
+
// Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/tsoa-next/tsoa-next
|
|
75
64
|
// ###########################################################################################################
|
|
76
65
|
|
|
77
66
|
{{#if useFileUploads}}
|
|
78
67
|
const upload = opts?.multer || multer({{{json multerOpts}}});
|
|
79
68
|
{{/if}}
|
|
69
|
+
const additionalProps: AdditionalProps = {
|
|
70
|
+
...{{{ json minimalSwaggerConfig}}},
|
|
71
|
+
validation: opts?.validation,
|
|
72
|
+
};
|
|
73
|
+
const templateService = new ExpressTemplateService(models, additionalProps);
|
|
74
|
+
|
|
80
75
|
|
|
81
|
-
|
|
82
76
|
{{#each controllers}}
|
|
83
77
|
{{#each actions}}
|
|
84
78
|
const args{{../name}}_{{name}}: Record<string, TsoaRoute.ParameterSchema> = {
|
|
@@ -107,11 +101,9 @@ export function RegisterRoutes(app: Router) {
|
|
|
107
101
|
|
|
108
102
|
async function {{../name}}_{{name}}(request: ExRequest, response: ExResponse, next: any) {
|
|
109
103
|
|
|
110
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
111
|
-
|
|
112
104
|
let validatedArgs: any[] = [];
|
|
113
105
|
try {
|
|
114
|
-
validatedArgs = templateService.getValidatedArgs({ args: args{{../name}}_{{name}}, request, response });
|
|
106
|
+
validatedArgs = templateService.getValidatedArgs({ args: args{{../name}}_{{name}}, controllerClass: {{../name}}, methodName: '{{name}}', request, response });
|
|
115
107
|
|
|
116
108
|
{{#if ../../iocModule}}
|
|
117
109
|
const container: IocContainer = typeof iocContainer === 'function' ? (iocContainer as IocContainerFactory)(request) : iocContainer;
|
|
@@ -136,21 +128,14 @@ export function RegisterRoutes(app: Router) {
|
|
|
136
128
|
return next(err);
|
|
137
129
|
}
|
|
138
130
|
});
|
|
139
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
140
131
|
{{/each}}
|
|
141
132
|
{{/each}}
|
|
142
133
|
|
|
143
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
144
|
-
|
|
145
134
|
{{#if useSecurity}}
|
|
146
135
|
|
|
147
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
148
|
-
|
|
149
136
|
function authenticateMiddleware(security: TsoaRoute.Security[] = []) {
|
|
150
137
|
return async function runAuthenticationMiddleware(request: any, response: any, next: any) {
|
|
151
138
|
|
|
152
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
153
|
-
|
|
154
139
|
// keep track of failed auth attempts so we can hand back the most
|
|
155
140
|
// recent one. This behavior was previously existing so preserving it
|
|
156
141
|
// here
|
|
@@ -172,7 +157,7 @@ export function RegisterRoutes(app: Router) {
|
|
|
172
157
|
);
|
|
173
158
|
}
|
|
174
159
|
|
|
175
|
-
|
|
160
|
+
|
|
176
161
|
|
|
177
162
|
secMethodOrPromises.push(Promise.all(secMethodAndPromises)
|
|
178
163
|
.then(users => { return users[0]; }));
|
|
@@ -186,7 +171,7 @@ export function RegisterRoutes(app: Router) {
|
|
|
186
171
|
}
|
|
187
172
|
}
|
|
188
173
|
|
|
189
|
-
|
|
174
|
+
|
|
190
175
|
|
|
191
176
|
try {
|
|
192
177
|
request['user'] = await Promise.any(secMethodOrPromises);
|
|
@@ -210,12 +195,12 @@ export function RegisterRoutes(app: Router) {
|
|
|
210
195
|
next(error);
|
|
211
196
|
}
|
|
212
197
|
|
|
213
|
-
|
|
198
|
+
|
|
214
199
|
}
|
|
215
200
|
}
|
|
216
201
|
{{/if}}
|
|
217
202
|
|
|
218
|
-
|
|
203
|
+
|
|
219
204
|
}
|
|
220
205
|
|
|
221
|
-
|
|
206
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/
|
|
4
|
-
import type { TsoaRoute } from '@tsoa-next/runtime';
|
|
3
|
+
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/tsoa-next/tsoa-next
|
|
4
|
+
import type { AdditionalProps, Tsoa, TsoaRoute } from '@tsoa-next/runtime';
|
|
5
5
|
import { fetchMiddlewares, HapiTemplateService } from '@tsoa-next/runtime';
|
|
6
6
|
{{#each controllers}}
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
import { {{name}} } from '{{modulePath}}';
|
|
9
9
|
{{/each}}
|
|
10
10
|
{{#if authenticationModule}}
|
|
@@ -18,7 +18,7 @@ import type { IocContainer, IocContainerFactory } from '@tsoa-next/runtime';
|
|
|
18
18
|
import { boomify, isBoom, type Payload } from '@hapi/boom';
|
|
19
19
|
import type { Request, ResponseToolkit, RouteOptionsPreAllOptions } from '@hapi/hapi';
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
|
|
23
23
|
const models: TsoaRoute.Models = {
|
|
24
24
|
{{#each models}}
|
|
@@ -41,22 +41,25 @@ const models: TsoaRoute.Models = {
|
|
|
41
41
|
"type": {{{json type}}},
|
|
42
42
|
{{/if}}
|
|
43
43
|
},
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
{{/each}}
|
|
46
46
|
};
|
|
47
|
-
const templateService = new HapiTemplateService(
|
|
48
|
-
models,
|
|
49
|
-
{{{ json minimalSwaggerConfig }}},
|
|
50
|
-
{ boomify, isBoom },
|
|
51
|
-
);
|
|
52
47
|
|
|
53
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
54
48
|
|
|
55
|
-
export function RegisterRoutes(server: any) {
|
|
49
|
+
export function RegisterRoutes(server: any, opts?: { validation?: Tsoa.ValidationContext }) {
|
|
56
50
|
// ###########################################################################################################
|
|
57
51
|
// NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look
|
|
58
|
-
// Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/
|
|
52
|
+
// Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/tsoa-next/tsoa-next
|
|
59
53
|
// ###########################################################################################################
|
|
54
|
+
const additionalProps: AdditionalProps = {
|
|
55
|
+
...{{{ json minimalSwaggerConfig }}},
|
|
56
|
+
validation: opts?.validation,
|
|
57
|
+
};
|
|
58
|
+
const templateService = new HapiTemplateService(
|
|
59
|
+
models,
|
|
60
|
+
additionalProps,
|
|
61
|
+
{ boomify, isBoom },
|
|
62
|
+
);
|
|
60
63
|
{{#each controllers}}
|
|
61
64
|
{{#each actions}}
|
|
62
65
|
const args{{../name}}_{{name}}: Record<string, TsoaRoute.ParameterSchema> = {
|
|
@@ -100,7 +103,7 @@ export function RegisterRoutes(server: any) {
|
|
|
100
103
|
|
|
101
104
|
let validatedArgs: any[] = [];
|
|
102
105
|
try {
|
|
103
|
-
validatedArgs = templateService.getValidatedArgs({ args: args{{../name}}_{{name}}, request, h });
|
|
106
|
+
validatedArgs = templateService.getValidatedArgs({ args: args{{../name}}_{{name}}, controllerClass: {{../name}}, methodName: '{{name}}', request, h });
|
|
104
107
|
} catch (err) {
|
|
105
108
|
const error = err as any;
|
|
106
109
|
if (isBoom(error)) {
|
|
@@ -138,18 +141,18 @@ export function RegisterRoutes(server: any) {
|
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
143
|
});
|
|
141
|
-
|
|
144
|
+
|
|
142
145
|
{{/each}}
|
|
143
146
|
{{/each}}
|
|
144
147
|
|
|
145
148
|
{{#if useSecurity}}
|
|
146
149
|
|
|
147
|
-
|
|
150
|
+
|
|
148
151
|
|
|
149
152
|
function authenticateMiddleware(security: TsoaRoute.Security[] = []) {
|
|
150
153
|
return async function runAuthenticationMiddleware(request: any, h: any) {
|
|
151
154
|
|
|
152
|
-
|
|
155
|
+
|
|
153
156
|
|
|
154
157
|
// keep track of failed auth attempts so we can hand back the most
|
|
155
158
|
// recent one. This behavior was previously existing so preserving it
|
|
@@ -172,7 +175,7 @@ export function RegisterRoutes(server: any) {
|
|
|
172
175
|
);
|
|
173
176
|
}
|
|
174
177
|
|
|
175
|
-
|
|
178
|
+
|
|
176
179
|
|
|
177
180
|
secMethodOrPromises.push(Promise.all(secMethodAndPromises)
|
|
178
181
|
.then(users => { return users[0]; }));
|
|
@@ -186,7 +189,7 @@ export function RegisterRoutes(server: any) {
|
|
|
186
189
|
}
|
|
187
190
|
}
|
|
188
191
|
|
|
189
|
-
|
|
192
|
+
|
|
190
193
|
|
|
191
194
|
try {
|
|
192
195
|
request['user'] = await Promise.any(secMethodOrPromises);
|
|
@@ -209,7 +212,7 @@ export function RegisterRoutes(server: any) {
|
|
|
209
212
|
throw boomErr;
|
|
210
213
|
}
|
|
211
214
|
|
|
212
|
-
|
|
215
|
+
|
|
213
216
|
}
|
|
214
217
|
}
|
|
215
218
|
{{/if}}
|
|
@@ -261,7 +264,7 @@ export function RegisterRoutes(server: any) {
|
|
|
261
264
|
}
|
|
262
265
|
{{/if}}
|
|
263
266
|
|
|
264
|
-
|
|
267
|
+
|
|
265
268
|
}
|
|
266
269
|
|
|
267
|
-
|
|
270
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/
|
|
4
|
-
import type { TsoaRoute } from '@tsoa-next/runtime';
|
|
3
|
+
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/tsoa-next/tsoa-next
|
|
4
|
+
import type { AdditionalProps, Tsoa, TsoaRoute } from '@tsoa-next/runtime';
|
|
5
5
|
import { fetchMiddlewares, KoaTemplateService } from '@tsoa-next/runtime';
|
|
6
6
|
{{#each controllers}}
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
import { {{name}} } from '{{modulePath}}';
|
|
9
9
|
{{/each}}
|
|
10
10
|
{{#if authenticationModule}}
|
|
@@ -29,7 +29,7 @@ const koaAuthenticationRecasted = koaAuthentication as (req: KRequest, securityN
|
|
|
29
29
|
{{/if}}
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
|
|
34
34
|
const models: TsoaRoute.Models = {
|
|
35
35
|
{{#each models}}
|
|
@@ -52,28 +52,28 @@ const models: TsoaRoute.Models = {
|
|
|
52
52
|
"type": {{{json type}}},
|
|
53
53
|
{{/if}}
|
|
54
54
|
},
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
{{/each}}
|
|
57
57
|
};
|
|
58
|
-
const templateService = new KoaTemplateService(models, {{{ json minimalSwaggerConfig }}});
|
|
59
|
-
|
|
60
|
-
// WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa
|
|
61
|
-
|
|
62
|
-
|
|
63
58
|
{{#if useFileUploads}}
|
|
64
|
-
export function RegisterRoutes(router: KoaRouter,opts?:{multer?:ReturnType<typeof multer
|
|
59
|
+
export function RegisterRoutes(router: KoaRouter,opts?:{multer?:ReturnType<typeof multer>; validation?: Tsoa.ValidationContext}) {
|
|
65
60
|
{{else}}
|
|
66
|
-
export function RegisterRoutes(router: KoaRouter) {
|
|
61
|
+
export function RegisterRoutes(router: KoaRouter,opts?:{validation?: Tsoa.ValidationContext}) {
|
|
67
62
|
{{/if}}
|
|
68
63
|
|
|
69
64
|
// ###########################################################################################################
|
|
70
65
|
// NOTE: If you do not see routes for all of your controllers in this file, then you might not have informed tsoa of where to look
|
|
71
|
-
// Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/
|
|
66
|
+
// Please look into the "controllerPathGlobs" config option described in the readme: https://github.com/tsoa-next/tsoa-next
|
|
72
67
|
// ###########################################################################################################
|
|
73
68
|
|
|
74
69
|
{{#if useFileUploads}}
|
|
75
70
|
const upload = opts?.multer || multer({{{json multerOpts}}});
|
|
76
71
|
{{/if}}
|
|
72
|
+
const additionalProps: AdditionalProps = {
|
|
73
|
+
...{{{ json minimalSwaggerConfig }}},
|
|
74
|
+
validation: opts?.validation,
|
|
75
|
+
};
|
|
76
|
+
const templateService = new KoaTemplateService(models, additionalProps);
|
|
77
77
|
|
|
78
78
|
{{#each controllers}}
|
|
79
79
|
{{#each actions}}
|
|
@@ -105,7 +105,7 @@ export function RegisterRoutes(router: KoaRouter) {
|
|
|
105
105
|
|
|
106
106
|
let validatedArgs: any[] = [];
|
|
107
107
|
try {
|
|
108
|
-
validatedArgs = templateService.getValidatedArgs({ args: args{{../name}}_{{name}}, context, next });
|
|
108
|
+
validatedArgs = templateService.getValidatedArgs({ args: args{{../name}}_{{name}}, controllerClass: {{../name}}, methodName: '{{name}}', context, next });
|
|
109
109
|
} catch (err) {
|
|
110
110
|
const error = err as any;
|
|
111
111
|
error.message ||= JSON.stringify({ fields: error.fields });
|
|
@@ -132,18 +132,18 @@ export function RegisterRoutes(router: KoaRouter) {
|
|
|
132
132
|
successStatus: {{successStatus}},
|
|
133
133
|
});
|
|
134
134
|
});
|
|
135
|
-
|
|
135
|
+
|
|
136
136
|
{{/each}}
|
|
137
137
|
{{/each}}
|
|
138
138
|
|
|
139
139
|
{{#if useSecurity}}
|
|
140
140
|
|
|
141
|
-
|
|
141
|
+
|
|
142
142
|
|
|
143
143
|
function authenticateMiddleware(security: TsoaRoute.Security[] = []) {
|
|
144
144
|
return async function runAuthenticationMiddleware(context: any, next: any) {
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
|
|
148
148
|
// keep track of failed auth attempts so we can hand back the most
|
|
149
149
|
// recent one. This behavior was previously existing so preserving it
|
|
@@ -178,7 +178,7 @@ export function RegisterRoutes(router: KoaRouter) {
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
|
|
182
182
|
|
|
183
183
|
let success;
|
|
184
184
|
try {
|
|
@@ -207,12 +207,12 @@ export function RegisterRoutes(router: KoaRouter) {
|
|
|
207
207
|
await next();
|
|
208
208
|
}
|
|
209
209
|
|
|
210
|
-
|
|
210
|
+
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
{{/if}}
|
|
214
214
|
|
|
215
|
-
|
|
215
|
+
|
|
216
216
|
}
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
|
|
@@ -19,6 +19,7 @@ export declare abstract class SpecGenerator {
|
|
|
19
19
|
} | {
|
|
20
20
|
[propertyName: string]: Swagger.Schema31;
|
|
21
21
|
};
|
|
22
|
+
protected getPropertySchemaType(type: Tsoa.Type): Tsoa.Type;
|
|
22
23
|
getSwaggerTypeForObjectLiteral(objectLiteral: Tsoa.NestedObjectLiteralType, title?: string): Swagger.BaseSchema;
|
|
23
24
|
protected getSwaggerTypeForReferenceType(_referenceType: Tsoa.ReferenceType): Swagger.BaseSchema;
|
|
24
25
|
protected getSwaggerTypeForVoid(_dataType: 'void' | 'undefined'): Swagger.BaseSchema;
|
|
@@ -29,6 +30,9 @@ export declare abstract class SpecGenerator {
|
|
|
29
30
|
protected abstract getSwaggerTypeForEnumType(enumType: Tsoa.EnumType, title?: string): Swagger.Schema2 | Swagger.Schema3;
|
|
30
31
|
protected hasUndefined(property: Tsoa.Property): boolean;
|
|
31
32
|
protected queriesPropertyToQueryParameter(property: Tsoa.Property): Tsoa.Parameter;
|
|
33
|
+
protected getExternalValidatorExtension(source: Pick<Tsoa.Parameter, 'externalValidator'>): {
|
|
34
|
+
'x-schema-validator'?: Tsoa.ExternalValidatorKind;
|
|
35
|
+
};
|
|
32
36
|
protected isRequiredWithoutDefault(prop: Tsoa.Property | Tsoa.Parameter): boolean | undefined;
|
|
33
37
|
protected getSchemaValidators(validators: Tsoa.Validators): Partial<Record<Tsoa.SchemaValidatorKey, unknown>>;
|
|
34
38
|
protected transformSchemaValidators(validators: Partial<Record<Tsoa.SchemaValidatorKey, unknown>>): Partial<Record<Tsoa.SchemaValidatorKey, unknown>>;
|
|
@@ -163,6 +163,22 @@ class SpecGenerator {
|
|
|
163
163
|
return (0, runtime_1.assertNever)(type);
|
|
164
164
|
}
|
|
165
165
|
}
|
|
166
|
+
getPropertySchemaType(type) {
|
|
167
|
+
const unwrapBrandedAlias = (current) => {
|
|
168
|
+
if (current.dataType === 'refAlias') {
|
|
169
|
+
const next = current.type;
|
|
170
|
+
if (next.dataType === 'intersection' && next.types.length === 1) {
|
|
171
|
+
return unwrapBrandedAlias(next.types[0]);
|
|
172
|
+
}
|
|
173
|
+
return current;
|
|
174
|
+
}
|
|
175
|
+
if (current.dataType === 'intersection' && current.types.length === 1) {
|
|
176
|
+
return unwrapBrandedAlias(current.types[0]);
|
|
177
|
+
}
|
|
178
|
+
return current;
|
|
179
|
+
};
|
|
180
|
+
return unwrapBrandedAlias(type);
|
|
181
|
+
}
|
|
166
182
|
getSwaggerTypeForObjectLiteral(objectLiteral, title) {
|
|
167
183
|
const properties = this.buildProperties(objectLiteral.properties);
|
|
168
184
|
const additionalProperties = objectLiteral.additionalProperties && this.getSwaggerType(objectLiteral.additionalProperties);
|
|
@@ -270,9 +286,13 @@ class SpecGenerator {
|
|
|
270
286
|
type: property.type,
|
|
271
287
|
default: property.default,
|
|
272
288
|
validators: property.validators,
|
|
289
|
+
parameterIndex: undefined,
|
|
273
290
|
deprecated: property.deprecated,
|
|
274
291
|
};
|
|
275
292
|
}
|
|
293
|
+
getExternalValidatorExtension(source) {
|
|
294
|
+
return source.externalValidator ? { 'x-schema-validator': source.externalValidator.kind } : {};
|
|
295
|
+
}
|
|
276
296
|
isRequiredWithoutDefault(prop) {
|
|
277
297
|
return prop.required && prop.default == null;
|
|
278
298
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specGenerator.js","sourceRoot":"","sources":["../../src/swagger/specGenerator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAA+D;AAC/D,uDAAwC;AACxC,4DAAwE;AAExE,MAAM,cAAc,GAAG,CAAC,KAAc,EAAE,cAAc,GAAG,KAAK,EAAyB,EAAE;IACvF,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,cAAc,CAAA;IACvB,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;QACzF,OAAO,IAAI,CAAA;IACb,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;IACxD,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,cAAc,CAAC,IAAI,E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
33
33
|
};
|
|
34
|
-
const securityDefinitions = this.config.securityDefinitions
|
|
34
|
+
const securityDefinitions = this.config.securityDefinitions ?? {};
|
|
35
35
|
const supportedSchemes = ['basic', 'apiKey', 'oauth2'];
|
|
36
36
|
for (const { type } of Object.values(securityDefinitions)) {
|
|
37
37
|
if (!supportedSchemes.includes(type)) {
|
|
@@ -79,14 +79,14 @@ class SpecGenerator2 extends specGenerator_1.SpecGenerator {
|
|
|
79
79
|
}
|
|
80
80
|
buildDefinitions() {
|
|
81
81
|
const definitions = {};
|
|
82
|
-
Object.keys(this.metadata.referenceTypeMap).
|
|
82
|
+
Object.keys(this.metadata.referenceTypeMap).forEach(typeName => {
|
|
83
83
|
const referenceType = this.metadata.referenceTypeMap[typeName];
|
|
84
84
|
if (referenceType.dataType === 'refObject') {
|
|
85
85
|
const required = referenceType.properties.filter(p => this.isRequiredWithoutDefault(p) && !this.hasUndefined(p)).map(p => p.name);
|
|
86
86
|
definitions[referenceType.refName] = {
|
|
87
87
|
description: referenceType.description,
|
|
88
88
|
properties: this.buildProperties(referenceType.properties),
|
|
89
|
-
required: required
|
|
89
|
+
required: required.length > 0 ? Array.from(new Set(required)) : undefined,
|
|
90
90
|
type: 'object',
|
|
91
91
|
};
|
|
92
92
|
if (referenceType.additionalProperties) {
|
|
@@ -110,7 +110,7 @@ class SpecGenerator2 extends specGenerator_1.SpecGenerator {
|
|
|
110
110
|
enum: referenceType.enums,
|
|
111
111
|
type: this.decideEnumType(referenceType.enums, referenceType.refName),
|
|
112
112
|
};
|
|
113
|
-
if (this.config.xEnumVarnames && referenceType.enumVarnames
|
|
113
|
+
if (this.config.xEnumVarnames && referenceType.enumVarnames?.length === referenceType.enums.length) {
|
|
114
114
|
definitions[referenceType.refName]['x-enum-varnames'] = referenceType.enumVarnames;
|
|
115
115
|
}
|
|
116
116
|
if (referenceType.example) {
|
|
@@ -313,12 +313,14 @@ class SpecGenerator2 extends specGenerator_1.SpecGenerator {
|
|
|
313
313
|
...(parameterType.items && this.isSwaggerBaseSchema(parameterType.items) ? { items: this.toSwagger2Schema(parameterType.items) } : {}),
|
|
314
314
|
type: 'array',
|
|
315
315
|
...schemaValidators,
|
|
316
|
+
...this.getExternalValidatorExtension(source),
|
|
316
317
|
}
|
|
317
318
|
: source.type.dataType === 'any'
|
|
318
|
-
? { type: 'object', ...schemaValidators }
|
|
319
|
+
? { type: 'object', ...schemaValidators, ...this.getExternalValidatorExtension(source) }
|
|
319
320
|
: {
|
|
320
321
|
...this.toSwagger2Schema(parameterType),
|
|
321
322
|
...schemaValidators,
|
|
323
|
+
...this.getExternalValidatorExtension(source),
|
|
322
324
|
};
|
|
323
325
|
return {
|
|
324
326
|
description: source.description,
|
|
@@ -342,6 +344,7 @@ class SpecGenerator2 extends specGenerator_1.SpecGenerator {
|
|
|
342
344
|
...(parameterType.format ? { format: this.throwIfNotDataFormat(parameterType.format) } : {}),
|
|
343
345
|
...(parameterType.items ? { items: parameterType.items } : {}),
|
|
344
346
|
...(parameterType.enum ? { enum: parameterType.enum } : {}),
|
|
347
|
+
...this.getExternalValidatorExtension(source),
|
|
345
348
|
...parameterValidators,
|
|
346
349
|
};
|
|
347
350
|
const resolvedType = source.type.dataType === 'any' ? 'string' : parameterType.type ? this.throwIfNotDataType(parameterType.type) : undefined;
|
|
@@ -407,7 +410,7 @@ class SpecGenerator2 extends specGenerator_1.SpecGenerator {
|
|
|
407
410
|
buildProperties(source) {
|
|
408
411
|
const properties = {};
|
|
409
412
|
source.forEach(property => {
|
|
410
|
-
let swaggerType = this.getSwaggerType(property.type);
|
|
413
|
+
let swaggerType = this.getSwaggerType(this.getPropertySchemaType(property.type));
|
|
411
414
|
const format = property.format;
|
|
412
415
|
swaggerType.description = property.description;
|
|
413
416
|
swaggerType.example = property.example;
|