You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using this code, tsoa should be able to generate properly.
Current Behavior
Currently, tsoa generates the following code.
Notice the undefined randomly in there. That is because (speculation) tsoa requires the variable that the argument to handler gets assigned to to have a name.
app.post('/auth/v1/verify-email/verify-code',
...(fetchMiddlewares<RequestHandler>(VerifyEmailController)),
...(fetchMiddlewares<RequestHandler>(VerifyEmailController.prototype.verifyCodeRoute)),asyncfunctionVerifyEmailController_verifyCodeRoute(request: ExRequest,response: ExResponse,next: any){constargs: Record<string,TsoaRoute.ParameterSchema>={undefined: {"in":"body","required":true,"dataType":"nestedObjectLiteral","nestedProperties":{"code":{"dataType":"string","required":true},"email":{"dataType":"string","required":true}}},};// 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/tsoaletvalidatedArgs: any[]=[];try{validatedArgs=templateService.getValidatedArgs({ args, request, response });constcontroller=newVerifyEmailController();awaittemplateService.apiHandler({methodName: 'verifyCodeRoute',
controller,
response,
next,
validatedArgs,successStatus: undefined,});}catch(err){returnnext(err);}});
Possible Solution
Steps to Reproduce
Use the provided code (above) and try it yourself.
Context (Environment)
Version of the library: ^6.4.0
Version of NodeJS: v20.15.0
Confirm you were using yarn not npm: [x]
Detailed Description
It will default to body instead of undefined, depending on which @decorator is being used.
Breaking change?
The text was updated successfully, but these errors were encountered:
The quick fix, for anyone who comes across this issue, is to use a named variable instead of object property destructuring.
alexng353
changed the title
Destructuring handler argument within function declaration causes tsoa to generate invalid code
Destructuring handler argument within function declaration causes tsoa to generate invalid code (Property 'name' is missing in type)
Jul 29, 2024
I believe this is the same issue as found in #1582 . Another solution instead of changing the code would be to make it extremely obvious in the documentation that it is REQUIRED to use named arguments instead of object destructuring.
Sorting
I'm submitting a ...
I confirm that I
Expected Behavior
Using this code, tsoa should be able to generate properly.
Current Behavior
Currently, tsoa generates the following code.
Notice the
undefined
randomly in there. That is because (speculation) tsoa requires the variable that the argument tohandler
gets assigned to to have a name.Possible Solution
Steps to Reproduce
Context (Environment)
Version of the library: ^6.4.0
Version of NodeJS: v20.15.0
Detailed Description
It will default to
body
instead ofundefined
, depending on which @decorator is being used.Breaking change?
The text was updated successfully, but these errors were encountered: