tsoa @Route decorator with variable dosen't works in express app

1.1k Views Asked by At

I can't find any information wh @Route decorator doesn't work with a variable instead of "string".

A swagger definition generated with code below is wrong.

export const PATH_GROUP = "/my-path";

export enum PATHS {
  GetButtons = "/",
}

@Route(PATH_GROUP)
export class ButtonsController {
  @Get(PATH_GROUP.GetButtons)
  @Tags("Buttons")
  public static async getButtons(): Promise<ButtonViewModel[]> {
    const buttons = await buttonsService.getAllButtons();

    return buttons.map(button => button.toAddToViewModel());
  }
}

When I generate a new swagger definition it looks like: buttons-swagger-section

If I use strings instead of variable/enum everything works correctly.

@Route("/my-path")
export class ButtonsController {
  @Get("/")
  @Tags("Buttons")
  public static async getButtons(): Promise<ButtonViewModel[]> {
    const buttons = await buttonsService.getAllButtons();

    return buttons.map(button => button.toAddToViewModel());
  }
}

Is there any information about not using variables in tsoa decorators?

0

There are 0 best solutions below