【问题标题】:NestJS - How do I expose param in SwaggerNestJS - 如何在 Swagger 中公开参数
【发布时间】:2021-10-18 08:48:42
【问题描述】:

我正在使用 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);
  }

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

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

谢谢。

【问题讨论】:

    标签: swagger nestjs swagger-ui


    【解决方案1】:

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

    @ApiParam({
        name: 'id',
        description: 'Gets the Action id',
      })
    

    【讨论】:

      猜你喜欢
      • 2021-02-10
      • 2021-07-09
      • 2020-05-28
      • 1970-01-01
      • 2021-09-19
      • 2020-12-29
      • 2019-03-27
      • 2021-08-09
      • 2021-09-20
      相关资源
      最近更新 更多