我已经构建了一个RestEasy API并将它与Swagger UI关联。我被要求完成的任务是找到一种方法来减少方法签名中的查询参数,并在某种“DTO”中处理它们。使用Swagger-UI注解@FormParam字段@ApiParam
我原来实行将类似于:
@GET
@ApiOperation(value = "echo test value", notes = "echo test notes")
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Response.status.OK")
public Response echoTest(
@ApiParam("id") @QueryParameter("id") final int id,
@ApiParam("fName") @QueryParameter("fName") final String fName,
@ApiParam("sName") @QueryParameter("sName") final String sName) {
// handle request
}
我已经提取的查询参数处理到DTO,虽然现在我不知道该如何处理的事情扬鞭-UI端。据我猜测,我试图在DTO中注释字段,但这没有奏效。我当前的解决方案没有正确招摇的UI交互:
@GET
@ApiOperation(value = "echo test value", notes = "echo test notes")
@ApiResponse(code = HttpServletResponse.SC_OK, message = "Response.status.OK")
public Response echoTest(@ApiParam("form") @FormParam QueryDTO dto) {
//Handle request
}
QueryDTO.java:
public class QueryDTO {
@ApiParam(name = "id", value = "user id") @QueryParam("id") private int id;
@ApiParam(name = "fName", value = "user first name") @QueryParam("fName") private String fName;
@ApiParam(name = "sName", value = "user surname") @QueryParam("sName) private String sName;
// Getters,setters etc
}
不SwaggerUI支持这种类型的功能?我可以采取哪种方法来适合我的用例?任何建议或帮助表示赞赏,谢谢。
我在文档中注意到了这一点,现在尝试使用@BeanParam的解决方案 - 感谢。 – 2014-10-30 12:14:28