tsoa icon indicating copy to clipboard operation
tsoa copied to clipboard

expressAuthenticationRecasted functions is undefined in generated routes

Open skitscha opened this issue 6 months ago • 2 comments

Sorting

  • I'm submitting a ...

    • [ x] bug report
    • [ ] feature request
    • [ ] support request
  • I confirm that I

    • [ X ] used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

I expect that in the following code snippets, tsoa will properly enforce the security header that is defined in the swagger.json.

 securityDefinitions: {
      api_key: {
        type: "apiKey",
        name: "apikey",
        in: "header",
      },
    },
import { Controller, Get, Route, Security } from "tsoa";
import os from "os";
import { HealthResponse } from "types/health";

@Route("health")
@Security("apiKey")
export class HealthController extends Controller {
  /**
   * Returns health of the service. Used to determine whether a deployment is healthy.
   */
  @Get()
  public async getHealth(): Promise<HealthResponse> {
    return {
      nodeHost: os.hostname(),
      gitSha: process.env.GIT_COMMIT,
    };
  }
}

Current Behavior

Tsoa errors while attempting to build and generate swagger for this code.

error TS2304: Cannot find name 'expressAuthenticationRecasted'.

198                             expressAuthenticationRecasted(request, name, secMethod[name], response)

image

Possible Solution

You can see this error by copying the provided code blocks.

Steps to Reproduce

  1. Create a project with a apiKey security definition in the tsoa config file
  2. Use that security definition on a controller
  3. Attempt to build the api

Context (Environment)

Version of the library: 6.4.0 Version of NodeJS: 20.15.1

  • Confirm you were using yarn not npm: [ x ]

Detailed Description

N.A

Breaking change?

skitscha avatar Jul 29 '24 20:07 skitscha