lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.45k stars 494 forks source link

Add posibility to get a property from the Request - @Request("username") Decorator #1495

Closed erbg closed 7 months ago

erbg commented 11 months ago

Sorting

Expected Behavior

I would like to introduce a possibility to get the retorn of the @Security Decorator as a parameter to the Function. In the same way we could add a standard way to read a property out of the Request, this could be usefull for variables set in a Middleware function. In this way the parameters could have also typings.

Example for the Security docu:

import { Get, Route, Security, Response } from "tsoa";

@Route("secure")
export class SecureController {
  @Response<ErrorResponseModel>("Unexpected error")
  @Security("api_key")
  @Get("UserInfo")
  public async userInfo(@Request("user") user: UserResponseModel): Promise<UserResponseModel> {
    return Promise.resolve(user);
  }
}
github-actions[bot] commented 11 months ago

Hello there erbg 👋

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

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