@tsoa-next/cli 7.1.0
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 -0
- package/dist/cli.d.ts +44 -0
- package/dist/cli.js +356 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/metadataGeneration/controllerGenerator.d.ts +30 -0
- package/dist/metadataGeneration/controllerGenerator.js +229 -0
- package/dist/metadataGeneration/controllerGenerator.js.map +1 -0
- package/dist/metadataGeneration/exceptions.d.ts +13 -0
- package/dist/metadataGeneration/exceptions.js +53 -0
- package/dist/metadataGeneration/exceptions.js.map +1 -0
- package/dist/metadataGeneration/extension.d.ts +5 -0
- package/dist/metadataGeneration/extension.js +85 -0
- package/dist/metadataGeneration/extension.js.map +1 -0
- package/dist/metadataGeneration/initializer-value.d.ts +6 -0
- package/dist/metadataGeneration/initializer-value.js +154 -0
- package/dist/metadataGeneration/initializer-value.js.map +1 -0
- package/dist/metadataGeneration/metadataGenerator.d.ts +29 -0
- package/dist/metadataGeneration/metadataGenerator.js +220 -0
- package/dist/metadataGeneration/metadataGenerator.js.map +1 -0
- package/dist/metadataGeneration/methodGenerator.d.ts +45 -0
- package/dist/metadataGeneration/methodGenerator.js +367 -0
- package/dist/metadataGeneration/methodGenerator.js.map +1 -0
- package/dist/metadataGeneration/parameterGenerator.d.ts +33 -0
- package/dist/metadataGeneration/parameterGenerator.js +552 -0
- package/dist/metadataGeneration/parameterGenerator.js.map +1 -0
- package/dist/metadataGeneration/transformer/dateTransformer.d.ts +6 -0
- package/dist/metadataGeneration/transformer/dateTransformer.js +28 -0
- package/dist/metadataGeneration/transformer/dateTransformer.js.map +1 -0
- package/dist/metadataGeneration/transformer/enumTransformer.d.ts +12 -0
- package/dist/metadataGeneration/transformer/enumTransformer.js +75 -0
- package/dist/metadataGeneration/transformer/enumTransformer.js.map +1 -0
- package/dist/metadataGeneration/transformer/primitiveTransformer.d.ts +11 -0
- package/dist/metadataGeneration/transformer/primitiveTransformer.js +70 -0
- package/dist/metadataGeneration/transformer/primitiveTransformer.js.map +1 -0
- package/dist/metadataGeneration/transformer/propertyTransformer.d.ts +12 -0
- package/dist/metadataGeneration/transformer/propertyTransformer.js +101 -0
- package/dist/metadataGeneration/transformer/propertyTransformer.js.map +1 -0
- package/dist/metadataGeneration/transformer/referenceTransformer.d.ts +10 -0
- package/dist/metadataGeneration/transformer/referenceTransformer.js +81 -0
- package/dist/metadataGeneration/transformer/referenceTransformer.js.map +1 -0
- package/dist/metadataGeneration/transformer/transformer.d.ts +9 -0
- package/dist/metadataGeneration/transformer/transformer.js +39 -0
- package/dist/metadataGeneration/transformer/transformer.js.map +1 -0
- package/dist/metadataGeneration/typeResolver.d.ts +52 -0
- package/dist/metadataGeneration/typeResolver.js +1202 -0
- package/dist/metadataGeneration/typeResolver.js.map +1 -0
- package/dist/module/generate-routes.d.ts +9 -0
- package/dist/module/generate-routes.js +90 -0
- package/dist/module/generate-routes.js.map +1 -0
- package/dist/module/generate-spec.d.ts +9 -0
- package/dist/module/generate-spec.js +79 -0
- package/dist/module/generate-spec.js.map +1 -0
- package/dist/routeGeneration/defaultRouteGenerator.d.ts +12 -0
- package/dist/routeGeneration/defaultRouteGenerator.js +119 -0
- package/dist/routeGeneration/defaultRouteGenerator.js.map +1 -0
- package/dist/routeGeneration/routeGenerator.d.ts +56 -0
- package/dist/routeGeneration/routeGenerator.js +257 -0
- package/dist/routeGeneration/routeGenerator.js.map +1 -0
- package/dist/routeGeneration/templates/express.hbs +221 -0
- package/dist/routeGeneration/templates/hapi.hbs +267 -0
- package/dist/routeGeneration/templates/koa.hbs +218 -0
- package/dist/swagger/specGenerator.d.ts +33 -0
- package/dist/swagger/specGenerator.js +253 -0
- package/dist/swagger/specGenerator.js.map +1 -0
- package/dist/swagger/specGenerator2.d.ts +27 -0
- package/dist/swagger/specGenerator2.js +476 -0
- package/dist/swagger/specGenerator2.js.map +1 -0
- package/dist/swagger/specGenerator3.d.ts +158 -0
- package/dist/swagger/specGenerator3.js +646 -0
- package/dist/swagger/specGenerator3.js.map +1 -0
- package/dist/swagger/specGenerator31.d.ts +24 -0
- package/dist/swagger/specGenerator31.js +75 -0
- package/dist/swagger/specGenerator31.js.map +1 -0
- package/dist/utils/decoratorUtils.d.ts +9 -0
- package/dist/utils/decoratorUtils.js +118 -0
- package/dist/utils/decoratorUtils.js.map +1 -0
- package/dist/utils/flowUtils.d.ts +1 -0
- package/dist/utils/flowUtils.js +8 -0
- package/dist/utils/flowUtils.js.map +1 -0
- package/dist/utils/fs.d.ts +5 -0
- package/dist/utils/fs.js +55 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/genericTypeGuards.d.ts +1 -0
- package/dist/utils/genericTypeGuards.js +8 -0
- package/dist/utils/genericTypeGuards.js.map +1 -0
- package/dist/utils/headerTypeHelpers.d.ts +5 -0
- package/dist/utils/headerTypeHelpers.js +27 -0
- package/dist/utils/headerTypeHelpers.js.map +1 -0
- package/dist/utils/importClassesFromDirectories.d.ts +4 -0
- package/dist/utils/importClassesFromDirectories.js +20 -0
- package/dist/utils/importClassesFromDirectories.js.map +1 -0
- package/dist/utils/internalTypeGuards.d.ts +5 -0
- package/dist/utils/internalTypeGuards.js +66 -0
- package/dist/utils/internalTypeGuards.js.map +1 -0
- package/dist/utils/isVoidType.d.ts +2 -0
- package/dist/utils/isVoidType.js +16 -0
- package/dist/utils/isVoidType.js.map +1 -0
- package/dist/utils/jsDocUtils.d.ts +8 -0
- package/dist/utils/jsDocUtils.js +122 -0
- package/dist/utils/jsDocUtils.js.map +1 -0
- package/dist/utils/jsonUtils.d.ts +1 -0
- package/dist/utils/jsonUtils.js +12 -0
- package/dist/utils/jsonUtils.js.map +1 -0
- package/dist/utils/pathUtils.d.ts +9 -0
- package/dist/utils/pathUtils.js +37 -0
- package/dist/utils/pathUtils.js.map +1 -0
- package/dist/utils/specMerge.d.ts +2 -0
- package/dist/utils/specMerge.js +36 -0
- package/dist/utils/specMerge.js.map +1 -0
- package/dist/utils/swaggerUtils.d.ts +3 -0
- package/dist/utils/swaggerUtils.js +22 -0
- package/dist/utils/swaggerUtils.js.map +1 -0
- package/dist/utils/unspecifiedObject.d.ts +3 -0
- package/dist/utils/unspecifiedObject.js +3 -0
- package/dist/utils/unspecifiedObject.js.map +1 -0
- package/dist/utils/validatorUtils.d.ts +5 -0
- package/dist/utils/validatorUtils.js +241 -0
- package/dist/utils/validatorUtils.js.map +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"methodGenerator.js","sourceRoot":"","sources":["../../src/metadataGeneration/methodGenerator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,2CAA4B;AAC5B,oDAAgD;AAChD,8DAAiH;AACjH,sDAA6F;AAC7F,2CAA2C;AAC3C,6CAAoD;AAEpD,6DAAyD;AAGzD,iDAA6C;AAC7C,kEAA0D;AAI1D,MAAa,eAAe;IAOP;IACA;IACA;IACA;IACA;IACA;IACA;IAZT,MAAM,CAAa;IACnB,IAAI,CAAS;IACf,QAAQ,CAAW;IACnB,QAAQ,CAAS;IAEzB,YACmB,IAA0B,EAC1B,OAA0B,EAC1B,eAAgC,EAChC,UAAmB,EACnB,UAAqB,EACrB,cAAgC,EAChC,cAAwB;QANxB,SAAI,GAAJ,IAAI,CAAsB;QAC1B,YAAO,GAAP,OAAO,CAAmB;QAC1B,oBAAe,GAAf,eAAe,CAAiB;QAChC,eAAU,GAAV,UAAU,CAAS;QACnB,eAAU,GAAV,UAAU,CAAW;QACrB,mBAAc,GAAd,cAAc,CAAkB;QAChC,mBAAc,GAAd,cAAc,CAAU;QAEzC,IAAI,CAAC,uBAAuB,EAAE,CAAA;IAChC,CAAC;IAEM,OAAO;QACZ,OAAO,IAAI,CAAC,MAAM,KAAK,SAAS,IAAI,IAAI,CAAC,I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AkB,CAAC,QAA4B;QACrD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5B,OAAO,QAAQ,CAAA;QACjB,CAAC;aAAM,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACxC,OAAO,CAAC,QAAQ,CAAC,CAAA;QACnB,CAAC;QACD,OAAM;IACR,CAAC;CACF;AA9WD,0CA8WC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
import { MetadataGenerator } from './metadataGenerator';
|
|
3
|
+
import { Tsoa } from '@tsoa-next/runtime';
|
|
4
|
+
export declare class ParameterGenerator {
|
|
5
|
+
private readonly parameter;
|
|
6
|
+
private readonly method;
|
|
7
|
+
private readonly path;
|
|
8
|
+
private readonly current;
|
|
9
|
+
constructor(parameter: ts.ParameterDeclaration, method: string, path: string, current: MetadataGenerator);
|
|
10
|
+
Generate(): Tsoa.Parameter[];
|
|
11
|
+
private getRequestParameter;
|
|
12
|
+
private getRequestPropParameter;
|
|
13
|
+
private extractTsoaResponse;
|
|
14
|
+
private getResParameters;
|
|
15
|
+
private getProducesFromResHeaders;
|
|
16
|
+
private getBodyPropParameter;
|
|
17
|
+
private getBodyParameter;
|
|
18
|
+
private getHeaderParameter;
|
|
19
|
+
private getUploadedFileParameter;
|
|
20
|
+
private getFormFieldParameter;
|
|
21
|
+
private getQueriesParameters;
|
|
22
|
+
private validateQueriesProperties;
|
|
23
|
+
private getQueryParameters;
|
|
24
|
+
private getPathParameter;
|
|
25
|
+
private getParameterDescription;
|
|
26
|
+
private getParameterDeprecation;
|
|
27
|
+
private getParameterExample;
|
|
28
|
+
private supportBodyMethod;
|
|
29
|
+
private supportParameterDecorator;
|
|
30
|
+
private supportPathDataType;
|
|
31
|
+
private getValidatedType;
|
|
32
|
+
private getQueryParameterIsHidden;
|
|
33
|
+
}
|
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.ParameterGenerator = void 0;
|
|
37
|
+
const ts = __importStar(require("typescript"));
|
|
38
|
+
const decoratorUtils_1 = require("./../utils/decoratorUtils");
|
|
39
|
+
const jsDocUtils_1 = require("./../utils/jsDocUtils");
|
|
40
|
+
const validatorUtils_1 = require("./../utils/validatorUtils");
|
|
41
|
+
const exceptions_1 = require("./exceptions");
|
|
42
|
+
const initializer_value_1 = require("./initializer-value");
|
|
43
|
+
const typeResolver_1 = require("./typeResolver");
|
|
44
|
+
const headerTypeHelpers_1 = require("../utils/headerTypeHelpers");
|
|
45
|
+
class ParameterGenerator {
|
|
46
|
+
parameter;
|
|
47
|
+
method;
|
|
48
|
+
path;
|
|
49
|
+
current;
|
|
50
|
+
constructor(parameter, method, path, current) {
|
|
51
|
+
this.parameter = parameter;
|
|
52
|
+
this.method = method;
|
|
53
|
+
this.path = path;
|
|
54
|
+
this.current = current;
|
|
55
|
+
}
|
|
56
|
+
Generate() {
|
|
57
|
+
const decoratorName = (0, decoratorUtils_1.getNodeFirstDecoratorName)(this.parameter, identifier => this.supportParameterDecorator(identifier.text));
|
|
58
|
+
switch (decoratorName) {
|
|
59
|
+
case 'Request':
|
|
60
|
+
return [this.getRequestParameter(this.parameter)];
|
|
61
|
+
case 'RequestProp':
|
|
62
|
+
return [this.getRequestPropParameter(this.parameter)];
|
|
63
|
+
case 'Body':
|
|
64
|
+
return [this.getBodyParameter(this.parameter)];
|
|
65
|
+
case 'BodyProp':
|
|
66
|
+
return [this.getBodyPropParameter(this.parameter)];
|
|
67
|
+
case 'FormField':
|
|
68
|
+
return [this.getFormFieldParameter(this.parameter)];
|
|
69
|
+
case 'Header':
|
|
70
|
+
return [this.getHeaderParameter(this.parameter)];
|
|
71
|
+
case 'Query':
|
|
72
|
+
return this.getQueryParameters(this.parameter);
|
|
73
|
+
case 'Queries':
|
|
74
|
+
return [this.getQueriesParameters(this.parameter)];
|
|
75
|
+
case 'Path':
|
|
76
|
+
return [this.getPathParameter(this.parameter)];
|
|
77
|
+
case 'Res':
|
|
78
|
+
return this.getResParameters(this.parameter);
|
|
79
|
+
case 'Inject':
|
|
80
|
+
return [];
|
|
81
|
+
case 'UploadedFile':
|
|
82
|
+
return [this.getUploadedFileParameter(this.parameter)];
|
|
83
|
+
case 'UploadedFiles':
|
|
84
|
+
return [this.getUploadedFileParameter(this.parameter, true)];
|
|
85
|
+
default:
|
|
86
|
+
return [this.getPathParameter(this.parameter)];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
getRequestParameter(parameter) {
|
|
90
|
+
const parameterName = parameter.name.text;
|
|
91
|
+
return {
|
|
92
|
+
description: this.getParameterDescription(parameter),
|
|
93
|
+
in: 'request',
|
|
94
|
+
name: parameterName,
|
|
95
|
+
parameterName,
|
|
96
|
+
required: !parameter.questionToken && !parameter.initializer,
|
|
97
|
+
type: { dataType: 'object' },
|
|
98
|
+
validators: (0, validatorUtils_1.getParameterValidators)(this.parameter, parameterName),
|
|
99
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
getRequestPropParameter(parameter) {
|
|
103
|
+
const parameterName = parameter.name.text;
|
|
104
|
+
const type = this.getValidatedType(parameter);
|
|
105
|
+
const { examples: example, exampleLabels } = this.getParameterExample(parameter, parameterName);
|
|
106
|
+
return {
|
|
107
|
+
default: (0, initializer_value_1.getInitializerValue)(parameter.initializer, this.current.typeChecker, type),
|
|
108
|
+
description: this.getParameterDescription(parameter),
|
|
109
|
+
example,
|
|
110
|
+
exampleLabels,
|
|
111
|
+
in: 'request-prop',
|
|
112
|
+
name: (0, decoratorUtils_1.getNodeFirstDecoratorValue)(this.parameter, this.current.typeChecker, ident => ident.text === 'ParameterProp') || parameterName,
|
|
113
|
+
parameterName,
|
|
114
|
+
required: !parameter.questionToken && !parameter.initializer,
|
|
115
|
+
type,
|
|
116
|
+
validators: (0, validatorUtils_1.getParameterValidators)(this.parameter, parameterName),
|
|
117
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
extractTsoaResponse(typeNode) {
|
|
121
|
+
if (!typeNode || !ts.isTypeReferenceNode(typeNode)) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
124
|
+
if (typeNode.typeName.getText() === 'TsoaResponse') {
|
|
125
|
+
return typeNode;
|
|
126
|
+
}
|
|
127
|
+
const symbol = this.current.typeChecker.getTypeAtLocation(typeNode).aliasSymbol;
|
|
128
|
+
if (!symbol || !symbol.declarations) {
|
|
129
|
+
return undefined;
|
|
130
|
+
}
|
|
131
|
+
const declaration = symbol.declarations[0];
|
|
132
|
+
if (!ts.isTypeAliasDeclaration(declaration) || !ts.isTypeReferenceNode(declaration.type)) {
|
|
133
|
+
return undefined;
|
|
134
|
+
}
|
|
135
|
+
return declaration.type.typeName.getText() === 'TsoaResponse' ? declaration.type : undefined;
|
|
136
|
+
}
|
|
137
|
+
getResParameters(parameter) {
|
|
138
|
+
const parameterName = parameter.name.text;
|
|
139
|
+
const decorator = (0, decoratorUtils_1.getNodeFirstDecoratorValue)(this.parameter, this.current.typeChecker, ident => ident.text === 'Res') || parameterName;
|
|
140
|
+
if (!decorator) {
|
|
141
|
+
throw new exceptions_1.GenerateMetadataError('Could not find Decorator', parameter);
|
|
142
|
+
}
|
|
143
|
+
const typeNode = this.extractTsoaResponse(parameter.type);
|
|
144
|
+
if (!typeNode) {
|
|
145
|
+
throw new exceptions_1.GenerateMetadataError('@Res() requires the type to be TsoaResponse<HTTPStatusCode, ResBody>', parameter);
|
|
146
|
+
}
|
|
147
|
+
if (!typeNode.typeArguments || !typeNode.typeArguments[0]) {
|
|
148
|
+
throw new exceptions_1.GenerateMetadataError('@Res() requires the type to be TsoaResponse<HTTPStatusCode, ResBody>', parameter);
|
|
149
|
+
}
|
|
150
|
+
const statusArgument = typeNode.typeArguments[0];
|
|
151
|
+
const bodyArgument = typeNode.typeArguments[1];
|
|
152
|
+
// support a union of status codes, all with the same response body
|
|
153
|
+
const statusArguments = ts.isUnionTypeNode(statusArgument) ? [...statusArgument.types] : [statusArgument];
|
|
154
|
+
const statusArgumentTypes = statusArguments.map(a => this.current.typeChecker.getTypeAtLocation(a));
|
|
155
|
+
const isNumberLiteralType = (tsType) => {
|
|
156
|
+
// eslint-disable-next-line no-bitwise
|
|
157
|
+
return (tsType.getFlags() & ts.TypeFlags.NumberLiteral) !== 0;
|
|
158
|
+
};
|
|
159
|
+
const headers = (0, headerTypeHelpers_1.getHeaderType)(typeNode.typeArguments, 2, this.current);
|
|
160
|
+
return statusArgumentTypes.map(statusArgumentType => {
|
|
161
|
+
if (!isNumberLiteralType(statusArgumentType)) {
|
|
162
|
+
throw new exceptions_1.GenerateMetadataError('@Res() requires the type to be TsoaResponse<HTTPStatusCode, ResBody>', parameter);
|
|
163
|
+
}
|
|
164
|
+
const status = String(statusArgumentType.value);
|
|
165
|
+
const type = new typeResolver_1.TypeResolver(bodyArgument, this.current, typeNode).resolve();
|
|
166
|
+
const { examples, exampleLabels } = this.getParameterExample(parameter, parameterName);
|
|
167
|
+
return {
|
|
168
|
+
description: this.getParameterDescription(parameter) || '',
|
|
169
|
+
in: 'res',
|
|
170
|
+
name: status,
|
|
171
|
+
produces: headers ? this.getProducesFromResHeaders(headers) : undefined,
|
|
172
|
+
parameterName,
|
|
173
|
+
examples,
|
|
174
|
+
required: true,
|
|
175
|
+
type,
|
|
176
|
+
exampleLabels,
|
|
177
|
+
schema: type,
|
|
178
|
+
validators: {},
|
|
179
|
+
headers,
|
|
180
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
181
|
+
};
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
getProducesFromResHeaders(headers) {
|
|
185
|
+
const { properties } = headers;
|
|
186
|
+
const [contentTypeProp] = (properties || []).filter(p => p.name.toLowerCase() === 'content-type' && p.type.dataType === 'enum');
|
|
187
|
+
if (contentTypeProp) {
|
|
188
|
+
const type = contentTypeProp.type;
|
|
189
|
+
return type.enums;
|
|
190
|
+
}
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
getBodyPropParameter(parameter) {
|
|
194
|
+
const parameterName = parameter.name.text;
|
|
195
|
+
const type = this.getValidatedType(parameter);
|
|
196
|
+
if (!this.supportBodyMethod(this.method)) {
|
|
197
|
+
throw new exceptions_1.GenerateMetadataError(`@BodyProp('${parameterName}') Can't support in ${this.method.toUpperCase()} method.`);
|
|
198
|
+
}
|
|
199
|
+
const { examples: example, exampleLabels } = this.getParameterExample(parameter, parameterName);
|
|
200
|
+
return {
|
|
201
|
+
default: (0, initializer_value_1.getInitializerValue)(parameter.initializer, this.current.typeChecker, type),
|
|
202
|
+
description: this.getParameterDescription(parameter),
|
|
203
|
+
example,
|
|
204
|
+
exampleLabels,
|
|
205
|
+
in: 'body-prop',
|
|
206
|
+
name: (0, decoratorUtils_1.getNodeFirstDecoratorValue)(this.parameter, this.current.typeChecker, ident => ident.text === 'BodyProp') || parameterName,
|
|
207
|
+
parameterName,
|
|
208
|
+
required: !parameter.questionToken && !parameter.initializer,
|
|
209
|
+
type,
|
|
210
|
+
validators: (0, validatorUtils_1.getParameterValidators)(this.parameter, parameterName),
|
|
211
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
getBodyParameter(parameter) {
|
|
215
|
+
const parameterName = parameter.name.text;
|
|
216
|
+
const type = this.getValidatedType(parameter);
|
|
217
|
+
if (!this.supportBodyMethod(this.method)) {
|
|
218
|
+
throw new exceptions_1.GenerateMetadataError(`@Body('${parameterName}') Can't support in ${this.method.toUpperCase()} method.`);
|
|
219
|
+
}
|
|
220
|
+
const { examples: example, exampleLabels } = this.getParameterExample(parameter, parameterName);
|
|
221
|
+
return {
|
|
222
|
+
description: this.getParameterDescription(parameter),
|
|
223
|
+
in: 'body',
|
|
224
|
+
name: parameterName,
|
|
225
|
+
example,
|
|
226
|
+
exampleLabels,
|
|
227
|
+
parameterName,
|
|
228
|
+
required: !parameter.questionToken && !parameter.initializer,
|
|
229
|
+
type,
|
|
230
|
+
validators: (0, validatorUtils_1.getParameterValidators)(this.parameter, parameterName),
|
|
231
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
getHeaderParameter(parameter) {
|
|
235
|
+
const parameterName = parameter.name.text;
|
|
236
|
+
const type = this.getValidatedType(parameter);
|
|
237
|
+
if (!this.supportPathDataType(type)) {
|
|
238
|
+
throw new exceptions_1.GenerateMetadataError(`@Header('${parameterName}') Can't support '${type.dataType}' type.`);
|
|
239
|
+
}
|
|
240
|
+
const { examples: example, exampleLabels } = this.getParameterExample(parameter, parameterName);
|
|
241
|
+
return {
|
|
242
|
+
default: (0, initializer_value_1.getInitializerValue)(parameter.initializer, this.current.typeChecker, type),
|
|
243
|
+
description: this.getParameterDescription(parameter),
|
|
244
|
+
example,
|
|
245
|
+
exampleLabels,
|
|
246
|
+
in: 'header',
|
|
247
|
+
name: (0, decoratorUtils_1.getNodeFirstDecoratorValue)(this.parameter, this.current.typeChecker, ident => ident.text === 'Header') || parameterName,
|
|
248
|
+
parameterName,
|
|
249
|
+
required: !parameter.questionToken && !parameter.initializer,
|
|
250
|
+
type,
|
|
251
|
+
validators: (0, validatorUtils_1.getParameterValidators)(this.parameter, parameterName),
|
|
252
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
getUploadedFileParameter(parameter, isArray) {
|
|
256
|
+
const parameterName = parameter.name.text;
|
|
257
|
+
const elementType = { dataType: 'file' };
|
|
258
|
+
let type;
|
|
259
|
+
if (isArray) {
|
|
260
|
+
type = { dataType: 'array', elementType };
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
type = elementType;
|
|
264
|
+
}
|
|
265
|
+
if (!this.supportPathDataType(elementType)) {
|
|
266
|
+
throw new exceptions_1.GenerateMetadataError(`Parameter '${parameterName}:${type.dataType}' can't be passed as an uploaded file(s) parameter in '${this.method.toUpperCase()}'.`, parameter);
|
|
267
|
+
}
|
|
268
|
+
return {
|
|
269
|
+
description: this.getParameterDescription(parameter),
|
|
270
|
+
in: 'formData',
|
|
271
|
+
name: (0, decoratorUtils_1.getNodeFirstDecoratorValue)(this.parameter, this.current.typeChecker, ident => {
|
|
272
|
+
if (isArray) {
|
|
273
|
+
return ident.text === 'UploadedFiles';
|
|
274
|
+
}
|
|
275
|
+
return ident.text === 'UploadedFile';
|
|
276
|
+
}) ?? parameterName,
|
|
277
|
+
required: !parameter.questionToken && !parameter.initializer,
|
|
278
|
+
type,
|
|
279
|
+
parameterName,
|
|
280
|
+
validators: (0, validatorUtils_1.getParameterValidators)(this.parameter, parameterName),
|
|
281
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
getFormFieldParameter(parameter) {
|
|
285
|
+
const parameterName = parameter.name.text;
|
|
286
|
+
const type = this.getValidatedType(parameter);
|
|
287
|
+
if (!this.supportPathDataType(type)) {
|
|
288
|
+
throw new exceptions_1.GenerateMetadataError(`Parameter '${parameterName}:${type.dataType}' can't be passed as form field parameter in '${this.method.toUpperCase()}'.`, parameter);
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
description: this.getParameterDescription(parameter),
|
|
292
|
+
in: 'formData',
|
|
293
|
+
name: (0, decoratorUtils_1.getNodeFirstDecoratorValue)(this.parameter, this.current.typeChecker, ident => ident.text === 'FormField') ?? parameterName,
|
|
294
|
+
required: !parameter.questionToken && !parameter.initializer,
|
|
295
|
+
type,
|
|
296
|
+
parameterName,
|
|
297
|
+
validators: (0, validatorUtils_1.getParameterValidators)(this.parameter, parameterName),
|
|
298
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
getQueriesParameters(parameter) {
|
|
302
|
+
const parameterName = parameter.name.text;
|
|
303
|
+
const type = this.getValidatedType(parameter);
|
|
304
|
+
// Handle cases where TypeResolver doesn't properly resolve complex types
|
|
305
|
+
// like Zod's z.infer types to refObject or nestedObjectLiteral
|
|
306
|
+
if (type.dataType !== 'refObject' && type.dataType !== 'nestedObjectLiteral') {
|
|
307
|
+
// Try to resolve the type more aggressively for complex types
|
|
308
|
+
let typeNode = parameter.type;
|
|
309
|
+
if (!typeNode) {
|
|
310
|
+
const typeFromChecker = this.current.typeChecker.getTypeAtLocation(parameter);
|
|
311
|
+
typeNode = this.current.typeChecker.typeToTypeNode(typeFromChecker, undefined, ts.NodeBuilderFlags.NoTruncation);
|
|
312
|
+
}
|
|
313
|
+
// If it's a TypeReferenceNode (like z.infer), try to resolve it differently
|
|
314
|
+
if (ts.isTypeReferenceNode(typeNode)) {
|
|
315
|
+
try {
|
|
316
|
+
// Try to get the actual type from the type checker
|
|
317
|
+
const actualType = this.current.typeChecker.getTypeAtLocation(typeNode);
|
|
318
|
+
const typeNodeFromType = this.current.typeChecker.typeToTypeNode(actualType, undefined, ts.NodeBuilderFlags.NoTruncation);
|
|
319
|
+
const resolvedType = new typeResolver_1.TypeResolver(typeNodeFromType, this.current, parameter).resolve();
|
|
320
|
+
// Check if the resolved type is now acceptable
|
|
321
|
+
if (resolvedType.dataType === 'refObject' || resolvedType.dataType === 'nestedObjectLiteral') {
|
|
322
|
+
// Use the resolved type instead
|
|
323
|
+
for (const property of resolvedType.properties) {
|
|
324
|
+
this.validateQueriesProperties(property, parameterName);
|
|
325
|
+
}
|
|
326
|
+
const { examples: example, exampleLabels } = this.getParameterExample(parameter, parameterName);
|
|
327
|
+
return {
|
|
328
|
+
description: this.getParameterDescription(parameter),
|
|
329
|
+
in: 'queries',
|
|
330
|
+
name: parameterName,
|
|
331
|
+
example,
|
|
332
|
+
exampleLabels,
|
|
333
|
+
parameterName,
|
|
334
|
+
required: !parameter.questionToken && !parameter.initializer,
|
|
335
|
+
type: resolvedType,
|
|
336
|
+
validators: (0, validatorUtils_1.getParameterValidators)(this.parameter, parameterName),
|
|
337
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
catch (error) {
|
|
342
|
+
// If resolution fails, log the error for debugging but continue with the original error
|
|
343
|
+
// This helps developers understand why the type resolution failed
|
|
344
|
+
console.warn(`Failed to resolve complex type for @Queries('${parameterName}'):`, error);
|
|
345
|
+
// Continue with the original error below
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
throw new exceptions_1.GenerateMetadataError(`@Queries('${parameterName}') only support 'refObject' or 'nestedObjectLiteral' types. If you want only one query parameter, please use the '@Query' decorator.`);
|
|
349
|
+
}
|
|
350
|
+
for (const property of type.properties) {
|
|
351
|
+
this.validateQueriesProperties(property, parameterName);
|
|
352
|
+
}
|
|
353
|
+
const { examples: example, exampleLabels } = this.getParameterExample(parameter, parameterName);
|
|
354
|
+
return {
|
|
355
|
+
description: this.getParameterDescription(parameter),
|
|
356
|
+
in: 'queries',
|
|
357
|
+
name: parameterName,
|
|
358
|
+
example,
|
|
359
|
+
exampleLabels,
|
|
360
|
+
parameterName,
|
|
361
|
+
required: !parameter.questionToken && !parameter.initializer,
|
|
362
|
+
type,
|
|
363
|
+
validators: (0, validatorUtils_1.getParameterValidators)(this.parameter, parameterName),
|
|
364
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
validateQueriesProperties(property, parentName) {
|
|
368
|
+
if (property.type.dataType === 'array') {
|
|
369
|
+
const arrayType = property.type;
|
|
370
|
+
if (arrayType.elementType.dataType === 'nestedObjectLiteral') {
|
|
371
|
+
// For arrays of nestedObjectLiteral, validate each property recursively
|
|
372
|
+
const nestedType = arrayType.elementType;
|
|
373
|
+
if (nestedType.properties) {
|
|
374
|
+
for (const nestedProperty of nestedType.properties) {
|
|
375
|
+
this.validateQueriesProperties(nestedProperty, `${parentName}.${property.name}[]`);
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
else if (!this.supportPathDataType(arrayType.elementType)) {
|
|
380
|
+
throw new exceptions_1.GenerateMetadataError(`@Queries('${parentName}') property '${property.name}' can't support array '${arrayType.elementType.dataType}' type.`);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
else if (property.type.dataType === 'nestedObjectLiteral') {
|
|
384
|
+
// For nestedObjectLiteral, validate each property recursively
|
|
385
|
+
const nestedType = property.type;
|
|
386
|
+
if (nestedType.properties) {
|
|
387
|
+
for (const nestedProperty of nestedType.properties) {
|
|
388
|
+
this.validateQueriesProperties(nestedProperty, `${parentName}.${property.name}`);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
else if (!this.supportPathDataType(property.type)) {
|
|
393
|
+
throw new exceptions_1.GenerateMetadataError(`@Queries('${parentName}') nested property '${property.name}' Can't support '${property.type.dataType}' type.`);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
getQueryParameters(parameter) {
|
|
397
|
+
const parameterName = parameter.name.text;
|
|
398
|
+
const type = this.getValidatedType(parameter);
|
|
399
|
+
const { examples: example, exampleLabels } = this.getParameterExample(parameter, parameterName);
|
|
400
|
+
const commonProperties = {
|
|
401
|
+
default: (0, initializer_value_1.getInitializerValue)(parameter.initializer, this.current.typeChecker, type),
|
|
402
|
+
description: this.getParameterDescription(parameter),
|
|
403
|
+
example,
|
|
404
|
+
exampleLabels,
|
|
405
|
+
in: 'query',
|
|
406
|
+
name: (0, decoratorUtils_1.getNodeFirstDecoratorValue)(this.parameter, this.current.typeChecker, ident => ident.text === 'Query') || parameterName,
|
|
407
|
+
parameterName,
|
|
408
|
+
required: !parameter.questionToken && !parameter.initializer,
|
|
409
|
+
validators: (0, validatorUtils_1.getParameterValidators)(this.parameter, parameterName),
|
|
410
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
411
|
+
};
|
|
412
|
+
if (this.getQueryParameterIsHidden(parameter)) {
|
|
413
|
+
if (commonProperties.required) {
|
|
414
|
+
throw new exceptions_1.GenerateMetadataError(`@Query('${parameterName}') Can't support @Hidden because it is required (does not allow undefined and does not have a default value).`);
|
|
415
|
+
}
|
|
416
|
+
return [];
|
|
417
|
+
}
|
|
418
|
+
if (type.dataType === 'array') {
|
|
419
|
+
const arrayType = type;
|
|
420
|
+
if (!this.supportPathDataType(arrayType.elementType)) {
|
|
421
|
+
throw new exceptions_1.GenerateMetadataError(`@Query('${parameterName}') Can't support array '${arrayType.elementType.dataType}' type.`);
|
|
422
|
+
}
|
|
423
|
+
return [
|
|
424
|
+
{
|
|
425
|
+
...commonProperties,
|
|
426
|
+
collectionFormat: 'multi',
|
|
427
|
+
type: arrayType,
|
|
428
|
+
},
|
|
429
|
+
];
|
|
430
|
+
}
|
|
431
|
+
if (!this.supportPathDataType(type)) {
|
|
432
|
+
throw new exceptions_1.GenerateMetadataError(`@Query('${parameterName}') Can't support '${type.dataType}' type.`);
|
|
433
|
+
}
|
|
434
|
+
return [
|
|
435
|
+
{
|
|
436
|
+
...commonProperties,
|
|
437
|
+
type,
|
|
438
|
+
},
|
|
439
|
+
];
|
|
440
|
+
}
|
|
441
|
+
getPathParameter(parameter) {
|
|
442
|
+
const parameterName = parameter.name.text;
|
|
443
|
+
const type = this.getValidatedType(parameter);
|
|
444
|
+
const pathName = String((0, decoratorUtils_1.getNodeFirstDecoratorValue)(this.parameter, this.current.typeChecker, ident => ident.text === 'Path') || parameterName);
|
|
445
|
+
if (!this.supportPathDataType(type)) {
|
|
446
|
+
throw new exceptions_1.GenerateMetadataError(`@Path('${parameterName}') Can't support '${type.dataType}' type.`);
|
|
447
|
+
}
|
|
448
|
+
if (!this.path.includes(`{${pathName}}`) && !this.path.includes(`:${pathName}`)) {
|
|
449
|
+
throw new exceptions_1.GenerateMetadataError(`@Path('${parameterName}') Can't match in URL: '${this.path}'.`);
|
|
450
|
+
}
|
|
451
|
+
const { examples, exampleLabels } = this.getParameterExample(parameter, parameterName);
|
|
452
|
+
return {
|
|
453
|
+
default: (0, initializer_value_1.getInitializerValue)(parameter.initializer, this.current.typeChecker, type),
|
|
454
|
+
description: this.getParameterDescription(parameter),
|
|
455
|
+
example: examples,
|
|
456
|
+
exampleLabels,
|
|
457
|
+
in: 'path',
|
|
458
|
+
name: pathName,
|
|
459
|
+
parameterName,
|
|
460
|
+
required: true,
|
|
461
|
+
type,
|
|
462
|
+
validators: (0, validatorUtils_1.getParameterValidators)(this.parameter, parameterName),
|
|
463
|
+
deprecated: this.getParameterDeprecation(parameter),
|
|
464
|
+
};
|
|
465
|
+
}
|
|
466
|
+
getParameterDescription(node) {
|
|
467
|
+
const symbol = this.current.typeChecker.getSymbolAtLocation(node.name);
|
|
468
|
+
if (!symbol) {
|
|
469
|
+
return undefined;
|
|
470
|
+
}
|
|
471
|
+
const comments = symbol.getDocumentationComment(this.current.typeChecker);
|
|
472
|
+
if (comments.length) {
|
|
473
|
+
return ts.displayPartsToString(comments);
|
|
474
|
+
}
|
|
475
|
+
return undefined;
|
|
476
|
+
}
|
|
477
|
+
getParameterDeprecation(node) {
|
|
478
|
+
return (0, jsDocUtils_1.isExistJSDocTag)(node, tag => tag.tagName.text === 'deprecated') || (0, decoratorUtils_1.isDecorator)(node, identifier => identifier.text === 'Deprecated');
|
|
479
|
+
}
|
|
480
|
+
getParameterExample(node, parameterName) {
|
|
481
|
+
const exampleLabels = [];
|
|
482
|
+
const examples = (0, jsDocUtils_1.getJSDocTags)(node.parent, tag => {
|
|
483
|
+
const comment = (0, jsDocUtils_1.commentToString)(tag.comment);
|
|
484
|
+
const isExample = (tag.tagName.text === 'example' || tag.tagName.escapedText === 'example') && !!tag.comment && comment?.startsWith(parameterName);
|
|
485
|
+
if (isExample) {
|
|
486
|
+
const hasExampleLabel = (comment?.split(' ')[0].indexOf('.') || -1) > 0;
|
|
487
|
+
// custom example label is delimited by first '.' and the rest will all be included as example label
|
|
488
|
+
exampleLabels.push(hasExampleLabel ? comment?.split(' ')[0].split('.').slice(1).join('.') : undefined);
|
|
489
|
+
}
|
|
490
|
+
return isExample ?? false;
|
|
491
|
+
}).map(tag => ((0, jsDocUtils_1.commentToString)(tag.comment) || '').replace(`${(0, jsDocUtils_1.commentToString)(tag.comment)?.split(' ')[0] || ''}`, '').replace(/\r/g, ''));
|
|
492
|
+
if (examples.length === 0) {
|
|
493
|
+
return {
|
|
494
|
+
examples: undefined,
|
|
495
|
+
exampleLabels: undefined,
|
|
496
|
+
};
|
|
497
|
+
}
|
|
498
|
+
else {
|
|
499
|
+
try {
|
|
500
|
+
return {
|
|
501
|
+
examples: examples.map(example => JSON.parse(example)),
|
|
502
|
+
exampleLabels,
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
catch (e) {
|
|
506
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
507
|
+
throw new exceptions_1.GenerateMetadataError(`JSON format is incorrect: ${message}`);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
supportBodyMethod(method) {
|
|
512
|
+
return ['post', 'put', 'patch', 'delete'].some(m => m === method.toLowerCase());
|
|
513
|
+
}
|
|
514
|
+
supportParameterDecorator(decoratorName) {
|
|
515
|
+
return ['header', 'query', 'queries', 'path', 'body', 'bodyprop', 'request', 'requestprop', 'res', 'inject', 'uploadedfile', 'uploadedfiles', 'formfield'].some(d => d === decoratorName.toLocaleLowerCase());
|
|
516
|
+
}
|
|
517
|
+
supportPathDataType(parameterType) {
|
|
518
|
+
const supportedPathDataTypes = ['string', 'integer', 'long', 'float', 'double', 'date', 'datetime', 'buffer', 'boolean', 'enum', 'refEnum', 'file', 'any'];
|
|
519
|
+
if (supportedPathDataTypes.find(t => t === parameterType.dataType)) {
|
|
520
|
+
return true;
|
|
521
|
+
}
|
|
522
|
+
if (parameterType.dataType === 'refAlias') {
|
|
523
|
+
return this.supportPathDataType(parameterType.type);
|
|
524
|
+
}
|
|
525
|
+
if (parameterType.dataType === 'union') {
|
|
526
|
+
// skip undefined inside unions
|
|
527
|
+
return !parameterType.types.map(t => t.dataType === 'undefined' || this.supportPathDataType(t)).some(t => t === false);
|
|
528
|
+
}
|
|
529
|
+
return false;
|
|
530
|
+
}
|
|
531
|
+
getValidatedType(parameter) {
|
|
532
|
+
let typeNode = parameter.type;
|
|
533
|
+
if (!typeNode) {
|
|
534
|
+
const type = this.current.typeChecker.getTypeAtLocation(parameter);
|
|
535
|
+
typeNode = this.current.typeChecker.typeToTypeNode(type, undefined, ts.NodeBuilderFlags.NoTruncation);
|
|
536
|
+
}
|
|
537
|
+
return new typeResolver_1.TypeResolver(typeNode, this.current, parameter).resolve();
|
|
538
|
+
}
|
|
539
|
+
getQueryParameterIsHidden(parameter) {
|
|
540
|
+
const hiddenDecorators = (0, decoratorUtils_1.getDecorators)(parameter, identifier => identifier.text === 'Hidden');
|
|
541
|
+
if (!hiddenDecorators || !hiddenDecorators.length) {
|
|
542
|
+
return false;
|
|
543
|
+
}
|
|
544
|
+
if (hiddenDecorators.length > 1) {
|
|
545
|
+
const parameterName = parameter.name.text;
|
|
546
|
+
throw new exceptions_1.GenerateMetadataError(`Only one Hidden decorator allowed on @Query('${parameterName}').`);
|
|
547
|
+
}
|
|
548
|
+
return true;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
exports.ParameterGenerator = ParameterGenerator;
|
|
552
|
+
//# sourceMappingURL=parameterGenerator.js.map
|