@tsoa-next/runtime 7.1.0 → 7.3.1
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 +8 -2
- package/dist/config.d.ts +11 -4
- package/dist/decorators/example.d.ts +1 -1
- package/dist/decorators/example.js +1 -1
- package/dist/decorators/example.js.map +1 -1
- package/dist/decorators/methods.d.ts +7 -7
- package/dist/decorators/methods.js +7 -7
- package/dist/decorators/methods.js.map +1 -1
- package/dist/decorators/middlewares.d.ts +2 -1
- package/dist/decorators/middlewares.js +9 -6
- package/dist/decorators/middlewares.js.map +1 -1
- package/dist/decorators/operationid.d.ts +1 -1
- package/dist/decorators/operationid.js +1 -1
- package/dist/decorators/operationid.js.map +1 -1
- package/dist/decorators/parameter.d.ts +9 -9
- package/dist/decorators/parameter.js +9 -9
- package/dist/decorators/parameter.js.map +1 -1
- package/dist/decorators/response.d.ts +3 -3
- package/dist/decorators/response.js +3 -3
- package/dist/decorators/response.js.map +1 -1
- package/dist/decorators/route.d.ts +1 -1
- package/dist/decorators/route.js +1 -1
- package/dist/decorators/route.js.map +1 -1
- package/dist/decorators/security.d.ts +2 -2
- package/dist/decorators/security.js +1 -1
- package/dist/decorators/security.js.map +1 -1
- package/dist/decorators/tags.d.ts +1 -1
- package/dist/decorators/tags.js +1 -1
- package/dist/decorators/tags.js.map +1 -1
- package/dist/decorators/validate.d.ts +9 -0
- package/dist/decorators/validate.js +112 -0
- package/dist/decorators/validate.js.map +1 -0
- package/dist/index.d.ts +13 -11
- package/dist/index.js +13 -11
- package/dist/index.js.map +1 -1
- package/dist/interfaces/iocModule.d.ts +4 -2
- package/dist/interfaces/response.d.ts +1 -1
- package/dist/metadataGeneration/tsoa.d.ts +41 -9
- package/dist/routeGeneration/additionalProps.d.ts +2 -0
- package/dist/routeGeneration/externalValidation.d.ts +13 -0
- package/dist/routeGeneration/externalValidation.js +232 -0
- package/dist/routeGeneration/externalValidation.js.map +1 -0
- package/dist/routeGeneration/templateHelpers.d.ts +98 -21
- package/dist/routeGeneration/templateHelpers.js +305 -113
- package/dist/routeGeneration/templateHelpers.js.map +1 -1
- package/dist/routeGeneration/templates/express/expressTemplateService.d.ts +8 -4
- package/dist/routeGeneration/templates/express/expressTemplateService.js +32 -15
- package/dist/routeGeneration/templates/express/expressTemplateService.js.map +1 -1
- package/dist/routeGeneration/templates/hapi/hapiTemplateService.d.ts +22 -8
- package/dist/routeGeneration/templates/hapi/hapiTemplateService.js +67 -19
- package/dist/routeGeneration/templates/hapi/hapiTemplateService.js.map +1 -1
- package/dist/routeGeneration/templates/index.d.ts +1 -1
- package/dist/routeGeneration/templates/index.js +1 -1
- package/dist/routeGeneration/templates/index.js.map +1 -1
- package/dist/routeGeneration/templates/koa/koaTemplateService.d.ts +15 -6
- package/dist/routeGeneration/templates/koa/koaTemplateService.js +63 -22
- package/dist/routeGeneration/templates/koa/koaTemplateService.js.map +1 -1
- package/dist/routeGeneration/templates/templateService.d.ts +9 -4
- package/dist/routeGeneration/templates/templateService.js +39 -1
- package/dist/routeGeneration/templates/templateService.js.map +1 -1
- package/dist/routeGeneration/tsoa-route.d.ts +5 -0
- package/dist/swagger/swagger.d.ts +42 -41
- package/dist/swagger/swagger.js +4 -0
- package/dist/swagger/swagger.js.map +1 -1
- package/package.json +35 -6
|
@@ -2,28 +2,37 @@ import type { Context, Next } from 'koa';
|
|
|
2
2
|
import { Controller } from '../../../interfaces/controller';
|
|
3
3
|
import { TsoaRoute } from '../../tsoa-route';
|
|
4
4
|
import { TemplateService } from '../templateService';
|
|
5
|
+
type HeaderRecord = Record<string, string | string[] | undefined>;
|
|
5
6
|
type KoaApiHandlerParameters = {
|
|
6
7
|
methodName: string;
|
|
7
8
|
controller: Controller | object;
|
|
8
9
|
context: Context;
|
|
9
|
-
validatedArgs:
|
|
10
|
+
validatedArgs: unknown[];
|
|
10
11
|
successStatus?: number;
|
|
11
12
|
};
|
|
12
13
|
type KoaValidationArgsParameters = {
|
|
13
14
|
args: Record<string, TsoaRoute.ParameterSchema>;
|
|
15
|
+
controllerClass?: object;
|
|
16
|
+
methodName?: string;
|
|
14
17
|
context: Context;
|
|
15
18
|
next: Next;
|
|
16
19
|
};
|
|
17
20
|
type KoaReturnHandlerParameters = {
|
|
18
21
|
context: Context;
|
|
19
22
|
next?: Next;
|
|
20
|
-
headers:
|
|
23
|
+
headers: HeaderRecord | undefined;
|
|
21
24
|
statusCode?: number;
|
|
22
|
-
data?:
|
|
25
|
+
data?: unknown;
|
|
23
26
|
};
|
|
24
27
|
export declare class KoaTemplateService extends TemplateService<KoaApiHandlerParameters, KoaValidationArgsParameters, KoaReturnHandlerParameters> {
|
|
25
|
-
apiHandler(params: KoaApiHandlerParameters): Promise<
|
|
26
|
-
getValidatedArgs(params: KoaValidationArgsParameters):
|
|
27
|
-
protected returnHandler(params: KoaReturnHandlerParameters): Promise<
|
|
28
|
+
apiHandler(params: KoaApiHandlerParameters): Promise<void | Context>;
|
|
29
|
+
getValidatedArgs(params: KoaValidationArgsParameters): unknown[];
|
|
30
|
+
protected returnHandler(params: KoaReturnHandlerParameters): Promise<void> | Context | undefined;
|
|
31
|
+
private getRequestBody;
|
|
32
|
+
private getHeaderValue;
|
|
33
|
+
private getPathValue;
|
|
34
|
+
private getErrorStatus;
|
|
35
|
+
private getErrorMessage;
|
|
36
|
+
private getErrorProperties;
|
|
28
37
|
}
|
|
29
38
|
export {};
|
|
@@ -18,14 +18,20 @@ class KoaTemplateService extends templateService_1.TemplateService {
|
|
|
18
18
|
return this.returnHandler({ context, headers, statusCode, data });
|
|
19
19
|
}
|
|
20
20
|
catch (error) {
|
|
21
|
-
|
|
22
|
-
context.
|
|
21
|
+
const status = this.getErrorStatus(error) ?? 500;
|
|
22
|
+
context.status = status;
|
|
23
|
+
const properties = this.getErrorProperties(error);
|
|
24
|
+
if (properties) {
|
|
25
|
+
context.throw(status, this.getErrorMessage(error), properties);
|
|
26
|
+
}
|
|
27
|
+
context.throw(status, this.getErrorMessage(error));
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
getValidatedArgs(params) {
|
|
26
|
-
const { args, context, next } = params;
|
|
31
|
+
const { args, controllerClass, methodName, context, next } = params;
|
|
27
32
|
const errorFields = {};
|
|
28
33
|
const values = Object.values(args).map(param => {
|
|
34
|
+
const metadata = { controllerClass, methodName, parameterIndex: param.parameterIndex };
|
|
29
35
|
const name = param.name;
|
|
30
36
|
switch (param.in) {
|
|
31
37
|
case 'request':
|
|
@@ -33,31 +39,29 @@ class KoaTemplateService extends templateService_1.TemplateService {
|
|
|
33
39
|
case 'request-prop': {
|
|
34
40
|
const descriptor = Object.getOwnPropertyDescriptor(context.request, name);
|
|
35
41
|
const value = descriptor ? descriptor.value : undefined;
|
|
36
|
-
return this.validationService.ValidateParam(param, value, name, errorFields, false, undefined);
|
|
42
|
+
return this.validationService.ValidateParam(param, value, name, errorFields, false, undefined, metadata);
|
|
37
43
|
}
|
|
38
44
|
case 'query':
|
|
39
|
-
return this.validationService.ValidateParam(param, context.request.query[name], name, errorFields, false, undefined);
|
|
45
|
+
return this.validationService.ValidateParam(param, context.request.query[name], name, errorFields, false, undefined, metadata);
|
|
40
46
|
case 'queries':
|
|
41
|
-
return this.validationService.ValidateParam(param, context.request.query, name, errorFields, false, undefined);
|
|
47
|
+
return this.validationService.ValidateParam(param, context.request.query, name, errorFields, false, undefined, metadata);
|
|
42
48
|
case 'path':
|
|
43
|
-
return this.validationService.ValidateParam(param, context.params
|
|
49
|
+
return this.validationService.ValidateParam(param, this.getPathValue(context.params, name), name, errorFields, false, undefined, metadata);
|
|
44
50
|
case 'header':
|
|
45
|
-
return this.validationService.ValidateParam(param, context.request.headers
|
|
51
|
+
return this.validationService.ValidateParam(param, this.getHeaderValue(context.request.headers, name), name, errorFields, false, undefined, metadata);
|
|
46
52
|
case 'body': {
|
|
47
|
-
const
|
|
48
|
-
const value = descriptor ? descriptor.value : undefined;
|
|
53
|
+
const value = this.normalizeRequestBody(this.getRequestBody(context.request), context.request.headers);
|
|
49
54
|
const bodyFieldErrors = {};
|
|
50
|
-
const result = this.validationService.ValidateParam(param, value, name, bodyFieldErrors, true, undefined);
|
|
55
|
+
const result = this.validationService.ValidateParam(param, value, name, bodyFieldErrors, true, undefined, metadata);
|
|
51
56
|
Object.keys(bodyFieldErrors).forEach(key => {
|
|
52
57
|
errorFields[key] = { message: bodyFieldErrors[key].message };
|
|
53
58
|
});
|
|
54
59
|
return result;
|
|
55
60
|
}
|
|
56
61
|
case 'body-prop': {
|
|
57
|
-
const
|
|
58
|
-
const value = descriptor ? descriptor.value[name] : undefined;
|
|
62
|
+
const value = this.getBodyProperty(this.getRequestBody(context.request), context.request.headers, name);
|
|
59
63
|
const bodyFieldErrors = {};
|
|
60
|
-
const result = this.validationService.ValidateParam(param, value, name, bodyFieldErrors, true, 'body.');
|
|
64
|
+
const result = this.validationService.ValidateParam(param, value, name, bodyFieldErrors, true, 'body.', metadata);
|
|
61
65
|
Object.keys(bodyFieldErrors).forEach(key => {
|
|
62
66
|
errorFields[key] = { message: bodyFieldErrors[key].message };
|
|
63
67
|
});
|
|
@@ -67,18 +71,23 @@ class KoaTemplateService extends templateService_1.TemplateService {
|
|
|
67
71
|
const files = Object.values(args).filter(p => p.dataType === 'file' || (p.dataType === 'array' && p.array && p.array.dataType === 'file'));
|
|
68
72
|
const contextRequest = context.request;
|
|
69
73
|
if ((param.dataType === 'file' || (param.dataType === 'array' && param.array && param.array.dataType === 'file')) && files.length > 0) {
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
const rawFileValue = contextRequest.files?.[name];
|
|
75
|
+
let fileValue = rawFileValue;
|
|
76
|
+
if (param.dataType !== 'array' && Array.isArray(rawFileValue)) {
|
|
77
|
+
fileValue = rawFileValue[0];
|
|
73
78
|
}
|
|
74
|
-
|
|
79
|
+
const fileArgs = this.validationService.ValidateParam(param, fileValue, name, errorFields, false, undefined, metadata);
|
|
80
|
+
return fileArgs;
|
|
75
81
|
}
|
|
76
|
-
|
|
82
|
+
const bodyValue = this.isRecord(contextRequest.body) ? contextRequest.body[name] : undefined;
|
|
83
|
+
return this.validationService.ValidateParam(param, bodyValue, name, errorFields, false, undefined, metadata);
|
|
77
84
|
}
|
|
78
85
|
case 'res':
|
|
79
|
-
return async (status, data, headers) => {
|
|
86
|
+
return (async (status, data, headers) => {
|
|
80
87
|
await this.returnHandler({ context, headers, statusCode: status, data, next });
|
|
81
|
-
};
|
|
88
|
+
});
|
|
89
|
+
default:
|
|
90
|
+
return undefined;
|
|
82
91
|
}
|
|
83
92
|
});
|
|
84
93
|
if (Object.keys(errorFields).length > 0) {
|
|
@@ -102,7 +111,11 @@ class KoaTemplateService extends templateService_1.TemplateService {
|
|
|
102
111
|
if (statusCode) {
|
|
103
112
|
context.status = statusCode;
|
|
104
113
|
}
|
|
105
|
-
|
|
114
|
+
Object.entries(headers).forEach(([name, value]) => {
|
|
115
|
+
if (value !== undefined) {
|
|
116
|
+
context.set(name, value);
|
|
117
|
+
}
|
|
118
|
+
});
|
|
106
119
|
Object.defineProperty(context.response, koaTsoaResponsed, {
|
|
107
120
|
value: true,
|
|
108
121
|
writable: false,
|
|
@@ -111,6 +124,34 @@ class KoaTemplateService extends templateService_1.TemplateService {
|
|
|
111
124
|
}
|
|
112
125
|
return undefined;
|
|
113
126
|
}
|
|
127
|
+
getRequestBody(request) {
|
|
128
|
+
const requestWithBody = request;
|
|
129
|
+
return requestWithBody.body;
|
|
130
|
+
}
|
|
131
|
+
getHeaderValue(headers, name) {
|
|
132
|
+
return headers[name];
|
|
133
|
+
}
|
|
134
|
+
getPathValue(params, name) {
|
|
135
|
+
return params[name];
|
|
136
|
+
}
|
|
137
|
+
getErrorStatus(error) {
|
|
138
|
+
if (this.isRecord(error) && typeof error.status === 'number') {
|
|
139
|
+
return error.status;
|
|
140
|
+
}
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
getErrorMessage(error) {
|
|
144
|
+
if (error instanceof Error) {
|
|
145
|
+
return error.message;
|
|
146
|
+
}
|
|
147
|
+
if (this.isRecord(error) && typeof error.message === 'string') {
|
|
148
|
+
return error.message;
|
|
149
|
+
}
|
|
150
|
+
return 'Internal Server Error';
|
|
151
|
+
}
|
|
152
|
+
getErrorProperties(error) {
|
|
153
|
+
return this.isRecord(error) ? error : undefined;
|
|
154
|
+
}
|
|
114
155
|
}
|
|
115
156
|
exports.KoaTemplateService = KoaTemplateService;
|
|
116
157
|
//# sourceMappingURL=koaTemplateService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"koaTemplateService.js","sourceRoot":"","sources":["../../../../src/routeGeneration/templates/koa/koaTemplateService.ts"],"names":[],"mappings":";;;AAKA,2DAAqD;AACrD,wDAAoD;AAEpD,MAAM,gBAAgB,GAAG,MAAM,CAAC,yCAAyC,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"koaTemplateService.js","sourceRoot":"","sources":["../../../../src/routeGeneration/templates/koa/koaTemplateService.ts"],"names":[],"mappings":";;;AAKA,2DAAqD;AACrD,wDAAoD;AAEpD,MAAM,gBAAgB,GAAG,MAAM,CAAC,yCAAyC,CAAC,CAAA;AA8B1E,MAAa,kBAAmB,SAAQ,iCAAiG;IACvI,KAAK,CAAC,UAAU,CAAC,MAA+B;QAC9C,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,MAAM,CAAA;QAEhF,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,EAAE,UAAU,EAAE,aAAa,CAAC,CAAA;YAC3E,IAAI,UAAU,GAAG,aAAa,CAAA;YAC9B,IAAI,OAAiC,CAAA;YAErC,IAAI,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC;gBAClC,OAAO,GAAG,UAAU,CAAC,UAAU,EAAE,CAAA;gBACjC,UAAU,GAAG,UAAU,CAAC,SAAS,EAAE,IAAI,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C;YAC9D,OAAO,KAAK,CAAC,OAAO,CAAA;QACtB,CAAC;QAED,OAAO,uBAAuB,CAAA;IAChC,CAAC;IAEO,kBAAkB,CAAC,KAAc;QACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAA;IACjD,CAAC;CACF;AAnKD,gDAmKC"}
|
|
@@ -7,9 +7,14 @@ export declare abstract class TemplateService<ApiHandlerParameters, ValidationAr
|
|
|
7
7
|
protected readonly config: AdditionalProps;
|
|
8
8
|
protected validationService: ValidationService;
|
|
9
9
|
constructor(models: TsoaRoute.Models, config: AdditionalProps);
|
|
10
|
-
abstract apiHandler(params: ApiHandlerParameters): Promise<
|
|
11
|
-
abstract getValidatedArgs(params: ValidationArgsParameters):
|
|
12
|
-
protected abstract returnHandler(params: ReturnHandlerParameters):
|
|
10
|
+
abstract apiHandler(params: ApiHandlerParameters): Promise<unknown>;
|
|
11
|
+
abstract getValidatedArgs(params: ValidationArgsParameters): unknown[];
|
|
12
|
+
protected abstract returnHandler(params: ReturnHandlerParameters): unknown;
|
|
13
13
|
protected isController(object: Controller | object): object is Controller;
|
|
14
|
-
protected
|
|
14
|
+
protected requestHasBody(headers: Record<string, unknown>): boolean;
|
|
15
|
+
protected requestUsesTransferEncoding(headers: Record<string, unknown>): boolean;
|
|
16
|
+
protected normalizeRequestBody(body: unknown, headers: Record<string, unknown>): unknown;
|
|
17
|
+
protected getBodyProperty(body: unknown, headers: Record<string, unknown>, propertyName: string): unknown;
|
|
18
|
+
protected isRecord(value: unknown): value is Record<string, unknown>;
|
|
19
|
+
protected buildPromise(methodName: string, controller: Controller | object, validatedArgs: unknown[]): Promise<unknown>;
|
|
15
20
|
}
|
|
@@ -14,6 +14,39 @@ class TemplateService {
|
|
|
14
14
|
isController(object) {
|
|
15
15
|
return 'getHeaders' in object && 'getStatus' in object && 'setStatus' in object;
|
|
16
16
|
}
|
|
17
|
+
requestHasBody(headers) {
|
|
18
|
+
const contentLength = headers['content-length'];
|
|
19
|
+
if (Array.isArray(contentLength)) {
|
|
20
|
+
return contentLength.some(value => Number(value) > 0);
|
|
21
|
+
}
|
|
22
|
+
if (typeof contentLength === 'string') {
|
|
23
|
+
return Number(contentLength) > 0;
|
|
24
|
+
}
|
|
25
|
+
if (typeof contentLength === 'number') {
|
|
26
|
+
return contentLength > 0;
|
|
27
|
+
}
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
requestUsesTransferEncoding(headers) {
|
|
31
|
+
return headers['transfer-encoding'] !== undefined;
|
|
32
|
+
}
|
|
33
|
+
normalizeRequestBody(body, headers) {
|
|
34
|
+
if (this.requestHasBody(headers) || this.requestUsesTransferEncoding(headers)) {
|
|
35
|
+
return body;
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
getBodyProperty(body, headers, propertyName) {
|
|
40
|
+
const normalizedBody = this.normalizeRequestBody(body, headers);
|
|
41
|
+
if (!this.isRecord(normalizedBody)) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const descriptor = Object.getOwnPropertyDescriptor(normalizedBody, propertyName);
|
|
45
|
+
return descriptor ? descriptor.value : undefined;
|
|
46
|
+
}
|
|
47
|
+
isRecord(value) {
|
|
48
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
49
|
+
}
|
|
17
50
|
buildPromise(methodName, controller, validatedArgs) {
|
|
18
51
|
const ownPrototype = Object.getPrototypeOf(controller);
|
|
19
52
|
let prototype = ownPrototype;
|
|
@@ -30,7 +63,12 @@ class TemplateService {
|
|
|
30
63
|
// Keep previous behavior when nothing is found by allowing the same
|
|
31
64
|
// descriptor access failure path to occur on the original prototype.
|
|
32
65
|
const resolvedDescriptor = descriptor || Object.getOwnPropertyDescriptor(ownPrototype, methodName);
|
|
33
|
-
|
|
66
|
+
const method = resolvedDescriptor?.value;
|
|
67
|
+
if (typeof method !== 'function') {
|
|
68
|
+
throw new TypeError(`Controller method '${methodName}' is not callable`);
|
|
69
|
+
}
|
|
70
|
+
const callable = method;
|
|
71
|
+
return Promise.resolve(callable.apply(controller, validatedArgs));
|
|
34
72
|
}
|
|
35
73
|
}
|
|
36
74
|
exports.TemplateService = TemplateService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateService.js","sourceRoot":"","sources":["../../../src/routeGeneration/templates/templateService.ts"],"names":[],"mappings":";;;AAEA,wDAAsD;AAGtD,MAAsB,eAAe;IAId;IACA;IAJX,iBAAiB,CAAmB;IAE9C,YACqB,MAAwB,EACxB,MAAuB;QADvB,WAAM,GAAN,MAAM,CAAkB;QACxB,WAAM,GAAN,MAAM,CAAiB;QAE1C,IAAI,CAAC,iBAAiB,GAAG,IAAI,mCAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChE,CAAC;IAQS,YAAY,CAAC,MAA2B;QAChD,OAAO,YAAY,IAAI,MAAM,IAAI,WAAW,IAAI,MAAM,IAAI,WAAW,IAAI,MAAM,CAAA;IACjF,CAAC;IAES,YAAY,CAAC,UAAkB,EAAE,UAA+B,EAAE,
|
|
1
|
+
{"version":3,"file":"templateService.js","sourceRoot":"","sources":["../../../src/routeGeneration/templates/templateService.ts"],"names":[],"mappings":";;;AAEA,wDAAsD;AAGtD,MAAsB,eAAe;IAId;IACA;IAJX,iBAAiB,CAAmB;IAE9C,YACqB,MAAwB,EACxB,MAAuB;QADvB,WAAM,GAAN,MAAM,CAAkB;QACxB,WAAM,GAAN,MAAM,CAAiB;QAE1C,IAAI,CAAC,iBAAiB,GAAG,IAAI,mCAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChE,CAAC;IAQS,YAAY,CAAC,MAA2B;QAChD,OAAO,YAAY,IAAI,MAAM,IAAI,WAAW,IAAI,MAAM,IAAI,WAAW,IAAI,MAAM,CAAA;IACjF,CAAC;IAES,cAAc,CAAC,OAAgC;QACvD,MAAM,aAAa,GAAG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Route.RefObjectModelSchema['additionalProperties']): test is undefined;
|
|
7
7
|
export declare namespace TsoaRoute {
|
|
8
|
+
type ValidationStrategy = Tsoa.ValidationStrategy;
|
|
9
|
+
type ExternalValidatorDescriptor = Tsoa.ExternalValidatorDescriptor;
|
|
8
10
|
interface Models {
|
|
9
11
|
[name: string]: ModelSchema;
|
|
10
12
|
}
|
|
@@ -35,6 +37,8 @@ export declare namespace TsoaRoute {
|
|
|
35
37
|
dataType?: Tsoa.TypeStringLiteral;
|
|
36
38
|
ref?: string;
|
|
37
39
|
required?: boolean;
|
|
40
|
+
validationStrategy?: ValidationStrategy;
|
|
41
|
+
externalValidator?: ExternalValidatorDescriptor;
|
|
38
42
|
array?: PropertySchema;
|
|
39
43
|
enums?: Array<string | number | boolean | null>;
|
|
40
44
|
type?: PropertySchema;
|
|
@@ -47,6 +51,7 @@ export declare namespace TsoaRoute {
|
|
|
47
51
|
};
|
|
48
52
|
}
|
|
49
53
|
interface ParameterSchema extends PropertySchema {
|
|
54
|
+
parameterIndex?: number;
|
|
50
55
|
name: string;
|
|
51
56
|
in: string;
|
|
52
57
|
}
|
|
@@ -143,55 +143,49 @@ export declare namespace Swagger {
|
|
|
143
143
|
summary?: string;
|
|
144
144
|
description?: string;
|
|
145
145
|
}
|
|
146
|
-
|
|
146
|
+
type ParameterCommonFields = {
|
|
147
147
|
name: string;
|
|
148
|
-
in: 'query' | 'header' | 'path' | 'formData' | 'body' | 'cookie';
|
|
149
148
|
required?: boolean;
|
|
150
149
|
description?: string;
|
|
151
|
-
deprecated?: boolean;
|
|
152
150
|
[ext: `x-${string}`]: unknown;
|
|
153
|
-
} & Pick<BaseSchema, 'type' | 'items' | 'enum' | 'format' | 'minimum' | 'maximum' | 'minLength' | 'maxLength' | 'pattern'>;
|
|
154
|
-
export type BodyParameter = BaseParameter & {
|
|
155
|
-
in: 'body';
|
|
156
151
|
};
|
|
157
|
-
|
|
158
|
-
in: 'formData';
|
|
152
|
+
type Swagger2ParameterValue = Pick<BaseSchema, 'items' | 'enum' | 'minimum' | 'maximum' | 'minLength' | 'maxLength' | 'pattern'> & {
|
|
159
153
|
type: DataType;
|
|
160
154
|
format?: DataFormat;
|
|
161
|
-
collectionFormat?: 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi';
|
|
162
155
|
default?: unknown;
|
|
163
156
|
};
|
|
164
|
-
type
|
|
157
|
+
export type BodyParameter = ParameterCommonFields & {
|
|
158
|
+
in: 'body';
|
|
159
|
+
schema: Schema2;
|
|
160
|
+
};
|
|
161
|
+
export type FormDataParameter = ParameterCommonFields & Swagger2ParameterValue & {
|
|
162
|
+
in: 'formData';
|
|
163
|
+
collectionFormat?: 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi';
|
|
164
|
+
};
|
|
165
|
+
type QueryParameter = ParameterCommonFields & Swagger2ParameterValue & {
|
|
165
166
|
in: 'query';
|
|
166
|
-
type: DataType;
|
|
167
|
-
format?: DataFormat;
|
|
168
167
|
collectionFormat?: 'csv' | 'ssv' | 'tsv' | 'pipes' | 'multi';
|
|
169
|
-
default?: unknown;
|
|
170
168
|
};
|
|
171
|
-
type PathParameter =
|
|
169
|
+
type PathParameter = ParameterCommonFields & Swagger2ParameterValue & {
|
|
172
170
|
in: 'path';
|
|
173
|
-
type: DataType;
|
|
174
|
-
format?: DataFormat;
|
|
175
|
-
default?: unknown;
|
|
176
171
|
};
|
|
177
|
-
type HeaderParameter =
|
|
172
|
+
type HeaderParameter = ParameterCommonFields & Swagger2ParameterValue & {
|
|
178
173
|
in: 'header';
|
|
179
|
-
type: DataType;
|
|
180
|
-
format?: DataFormat;
|
|
181
|
-
default?: unknown;
|
|
182
174
|
};
|
|
183
|
-
type
|
|
184
|
-
|
|
175
|
+
type Swagger2NonBodyParameter = {
|
|
176
|
+
exclusiveMaximum?: boolean;
|
|
177
|
+
exclusiveMinimum?: boolean;
|
|
185
178
|
};
|
|
186
|
-
export type
|
|
187
|
-
export type
|
|
188
|
-
export type
|
|
189
|
-
export type
|
|
190
|
-
export type
|
|
191
|
-
export type Parameter2 = Swagger2BodyParameter | Swagger2FormDataParameter | Swagger2QueryParameter | Swagger2PathParameter | Swagger2HeaderParameter;
|
|
179
|
+
export type Swagger2FormDataParameter = FormDataParameter & Swagger2NonBodyParameter;
|
|
180
|
+
export type Swagger2QueryParameter = QueryParameter & Swagger2NonBodyParameter;
|
|
181
|
+
export type Swagger2PathParameter = PathParameter & Swagger2NonBodyParameter;
|
|
182
|
+
export type Swagger2HeaderParameter = HeaderParameter & Swagger2NonBodyParameter;
|
|
183
|
+
export type Parameter2 = BodyParameter | Swagger2FormDataParameter | Swagger2QueryParameter | Swagger2PathParameter | Swagger2HeaderParameter;
|
|
192
184
|
export function isQueryParameter(parameter: unknown): parameter is Swagger2QueryParameter;
|
|
193
|
-
export
|
|
185
|
+
export function isBodyParameter(parameter: unknown): parameter is BodyParameter;
|
|
186
|
+
export interface Parameter3 extends ParameterCommonFields {
|
|
194
187
|
in: 'query' | 'header' | 'path' | 'cookie';
|
|
188
|
+
deprecated?: boolean;
|
|
195
189
|
schema: Schema3;
|
|
196
190
|
style?: string;
|
|
197
191
|
explode?: boolean;
|
|
@@ -204,6 +198,7 @@ export declare namespace Swagger {
|
|
|
204
198
|
export interface Parameter31 extends Omit<Parameter3, 'schema'> {
|
|
205
199
|
schema: Schema31;
|
|
206
200
|
}
|
|
201
|
+
export type BaseParameter = Parameter2 | Parameter3 | Parameter31;
|
|
207
202
|
export interface Path {
|
|
208
203
|
$ref?: string;
|
|
209
204
|
get?: Operation;
|
|
@@ -309,14 +304,12 @@ export declare namespace Swagger {
|
|
|
309
304
|
}
|
|
310
305
|
export interface Response {
|
|
311
306
|
description: string;
|
|
312
|
-
schema?:
|
|
307
|
+
schema?: Schema2;
|
|
313
308
|
headers?: {
|
|
314
309
|
[name: string]: Header;
|
|
315
310
|
};
|
|
316
311
|
examples?: {
|
|
317
|
-
[responseMediaType: string]:
|
|
318
|
-
[exampleName: string]: Example3 | string;
|
|
319
|
-
};
|
|
312
|
+
[responseMediaType: string]: unknown;
|
|
320
313
|
};
|
|
321
314
|
}
|
|
322
315
|
export interface Response3 {
|
|
@@ -363,9 +356,7 @@ export declare namespace Swagger {
|
|
|
363
356
|
default?: string | boolean | number | unknown;
|
|
364
357
|
multipleOf?: number;
|
|
365
358
|
maximum?: number;
|
|
366
|
-
exclusiveMaximum?: number;
|
|
367
359
|
minimum?: number;
|
|
368
|
-
exclusiveMinimum?: number;
|
|
369
360
|
maxLength?: number;
|
|
370
361
|
minLength?: number;
|
|
371
362
|
pattern?: string;
|
|
@@ -389,8 +380,10 @@ export declare namespace Swagger {
|
|
|
389
380
|
required?: string[];
|
|
390
381
|
items?: BaseSchema;
|
|
391
382
|
}
|
|
392
|
-
export interface Schema31 extends Omit<Schema3, 'items' | 'properties' | 'additionalProperties' | 'discriminator' | 'anyOf' | 'allOf'> {
|
|
383
|
+
export interface Schema31 extends Omit<Schema3, 'items' | 'properties' | 'additionalProperties' | 'discriminator' | 'anyOf' | 'allOf' | 'exclusiveMaximum' | 'exclusiveMinimum'> {
|
|
393
384
|
examples?: unknown[];
|
|
385
|
+
exclusiveMaximum?: number;
|
|
386
|
+
exclusiveMinimum?: number;
|
|
394
387
|
properties?: {
|
|
395
388
|
[key: string]: Schema31;
|
|
396
389
|
};
|
|
@@ -408,18 +401,26 @@ export declare namespace Swagger {
|
|
|
408
401
|
mapping?: Record<string, string>;
|
|
409
402
|
};
|
|
410
403
|
}
|
|
411
|
-
export interface Schema3 extends Omit<BaseSchema, 'type'> {
|
|
404
|
+
export interface Schema3 extends Omit<BaseSchema, 'additionalProperties' | 'items' | 'properties' | 'type'> {
|
|
412
405
|
type?: DataType;
|
|
413
406
|
nullable?: boolean;
|
|
414
|
-
|
|
415
|
-
|
|
407
|
+
additionalProperties?: boolean | Schema3;
|
|
408
|
+
items?: Schema3;
|
|
409
|
+
anyOf?: Schema3[];
|
|
410
|
+
allOf?: Schema3[];
|
|
416
411
|
deprecated?: boolean;
|
|
412
|
+
exclusiveMaximum?: boolean;
|
|
413
|
+
exclusiveMinimum?: boolean;
|
|
417
414
|
properties?: {
|
|
418
415
|
[propertyName: string]: Schema3;
|
|
419
416
|
};
|
|
420
417
|
}
|
|
421
|
-
export interface Schema2 extends BaseSchema {
|
|
418
|
+
export interface Schema2 extends Omit<BaseSchema, 'additionalProperties' | 'items' | 'properties'> {
|
|
419
|
+
additionalProperties?: boolean | Schema2;
|
|
420
|
+
items?: Schema2;
|
|
422
421
|
type?: DataType;
|
|
422
|
+
exclusiveMaximum?: boolean;
|
|
423
|
+
exclusiveMinimum?: boolean;
|
|
423
424
|
properties?: {
|
|
424
425
|
[propertyName: string]: Schema2;
|
|
425
426
|
};
|
package/dist/swagger/swagger.js
CHANGED
|
@@ -8,5 +8,9 @@ var Swagger;
|
|
|
8
8
|
return typeof parameter === 'object' && parameter !== null && 'in' in parameter && parameter.in === 'query';
|
|
9
9
|
}
|
|
10
10
|
Swagger.isQueryParameter = isQueryParameter;
|
|
11
|
+
function isBodyParameter(parameter) {
|
|
12
|
+
return typeof parameter === 'object' && parameter !== null && 'in' in parameter && parameter.in === 'body';
|
|
13
|
+
}
|
|
14
|
+
Swagger.isBodyParameter = isBodyParameter;
|
|
11
15
|
})(Swagger || (exports.Swagger = Swagger = {}));
|
|
12
16
|
//# sourceMappingURL=swagger.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../src/swagger/swagger.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAC3D,IAAiB,OAAO,
|
|
1
|
+
{"version":3,"file":"swagger.js","sourceRoot":"","sources":["../../src/swagger/swagger.ts"],"names":[],"mappings":";;;AAAA,2DAA2D;AAC3D,IAAiB,OAAO,CAwjBvB;AAxjBD,WAAiB,OAAO;IAuLtB,SAAgB,gBAAgB,CAAC,SAAkB;QACjD,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,IAAI,IAAI,IAAI,SAAS,IAAI,SAAS,CAAC,EAAE,KAAK,OAAO,CAAA;IAC7G,CAAC;IAFe,wBAAgB,mBAE/B,CAAA;IAED,SAAgB,eAAe,CAAC,SAAkB;QAChD,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,IAAI,IAAI,IAAI,SAAS,IAAI,SAAS,CAAC,EAAE,KAAK,MAAM,CAAA;IAC5G,CAAC;IAFe,uBAAe,kBAE9B,CAAA;AA2XH,CAAC,EAxjBgB,OAAO,uBAAP,OAAO,QAwjBvB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsoa-next/runtime",
|
|
3
|
-
"version": "7.1
|
|
3
|
+
"version": "7.3.1",
|
|
4
4
|
"description": "Build swagger-compliant REST APIs using TypeScript and Node",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -42,23 +42,52 @@
|
|
|
42
42
|
"typescript": "^5.9.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"express": "^4.21.0 || ^5.0.0"
|
|
45
|
+
"express": "^4.21.0 || ^5.0.0",
|
|
46
|
+
"fp-ts": "^2.16.11",
|
|
47
|
+
"io-ts": "^2.2.21",
|
|
48
|
+
"io-ts-types": "^0.5.19",
|
|
49
|
+
"joi": "^17.13.3",
|
|
50
|
+
"superstruct": "^2.0.2",
|
|
51
|
+
"yup": "^1.7.1",
|
|
52
|
+
"zod": "^4.1.11"
|
|
46
53
|
},
|
|
47
54
|
"peerDependenciesMeta": {
|
|
48
55
|
"express": {
|
|
49
56
|
"optional": true
|
|
57
|
+
},
|
|
58
|
+
"fp-ts": {
|
|
59
|
+
"optional": true
|
|
60
|
+
},
|
|
61
|
+
"io-ts": {
|
|
62
|
+
"optional": true
|
|
63
|
+
},
|
|
64
|
+
"io-ts-types": {
|
|
65
|
+
"optional": true
|
|
66
|
+
},
|
|
67
|
+
"joi": {
|
|
68
|
+
"optional": true
|
|
69
|
+
},
|
|
70
|
+
"superstruct": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"yup": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"zod": {
|
|
77
|
+
"optional": true
|
|
50
78
|
}
|
|
51
79
|
},
|
|
52
80
|
"repository": {
|
|
53
81
|
"type": "git",
|
|
54
|
-
"url": "https://github.com/
|
|
82
|
+
"url": "https://github.com/tsoa-next/tsoa-next.git"
|
|
55
83
|
},
|
|
56
84
|
"engines": {
|
|
57
|
-
"node": ">=
|
|
58
|
-
"npm": ">=
|
|
85
|
+
"node": ">=22.0.0",
|
|
86
|
+
"npm": ">=10.0.0"
|
|
59
87
|
},
|
|
60
88
|
"engineStrict": true,
|
|
61
89
|
"publishConfig": {
|
|
62
90
|
"access": "public"
|
|
63
|
-
}
|
|
91
|
+
},
|
|
92
|
+
"homepage": "https://tsoa-next.dev"
|
|
64
93
|
}
|