如何使用swagger查询参数反序列化到类?

时间:2016-07-15 11:59:20

标签: java spring swagger

我有弹簧休息控制器,我希望通过swagger记录。它看起来像这样:

@ApiOperation(value = "Returns comments list")
@RequestMapping(method = RequestMethod.GET)
public CollectionResponse<CommentDTO> getComments(CommentFilterDTO filterDTO) {
    Page<CommentEntity> requisitionComments = commentService.getComments(filterDTO);
    return Convert.convert(requisitionComments, COMMENT_ENTITY_2_COMMENT_DTO);
}

CommentsFilterDTO是

public class CommentFilterDTO {
  private Long requisitionId;//get, set
  private CommentType commentType;//get, set
  // etc
}

这个控制器接受带有pageable和filterDTO参数的查询字符串,如下所示:

my/comments?requisitionId=1&commentType=COMMENT

现在我正试图通过招摇来记录它,我想要记录所有可能的查询参数,但如果我这样离开,我只看到 enter image description here 我可以通过@ApiImplicitParams记录查询参数,如

@ApiImplicitParams({
  @ApiImplicitParam(name = "requisitionId", value = "Requisition id", required = true, dataType = "long", paramType = "query"),
  ...   
})

有没有办法告诉swagger所有CommentFilterDTO字段都可以用作查询参数?

0 个答案:

没有答案