NestJS - 如何在 Swagger 中公开参数

Ved*_*ic. 1 swagger swagger-ui nestjs

我正在使用 NestJs。我有这个控制器:

@Get(':id')
  @ApiOperation({ summary: 'Get action by id' }) 
  findById(@Param('id') id: string, @Query() query?: SelectQuery & PopulateQuery): Promise<Action> {
    return this.actionService.findById(id, query);
  }
Run Code Online (Sandbox Code Playgroud)

当我在 Swagger 中打开页面时,它说没有可用的参数。

在Swagger中,如何将参数“id”作为输入框,以便我可以在Swagger(浏览器)中使用它?

谢谢。

Ved*_*ic. 6

在我发布问题后不久,我找到了答案。很简单。只需添加以下内容即可。

@ApiParam({
    name: 'id',
    description: 'Gets the Action id',
  })
Run Code Online (Sandbox Code Playgroud)