Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expressAuthenticationRecasted functions is undefined in generated routes #1655

Closed
2 tasks
skitscha opened this issue Jul 29, 2024 · 3 comments
Closed
2 tasks
Labels

Comments

@skitscha
Copy link

skitscha commented Jul 29, 2024

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?

Copy link

Hello there skitscha 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

@skitscha skitscha changed the title expressAuthenticationRecasted functions is undefined ingenerated routes expressAuthenticationRecasted functions is undefined in generated routes Jul 29, 2024
@s00d
Copy link

s00d commented Aug 10, 2024

hello, need authenticationModule - https://tsoa-community.github.io/docs/authentication.html#authentication

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants