我的Dropwizard API中有一个通用的响应对象,它是一个包含状态枚举和值的包装器 . API操作有响应或响应等响应 .
我一直试图找到一种方法来处理这个,并看到一些人提到这是为Spring Rest / Swagger处理的?
我正在使用:com.wordnik swagger-jaxrs_2.10 1.3.5
有没有人以一种很好的通用方式解决这个问题
围绕这个老问题,因为我正在为同一个问题寻找解决方案 . 这是我的解决方法:
@ApiModel public class PetListResponse extends Response<List<Pet>> { @Override @ApiModelProperty public List<Pet> getValue() { return super.getValue() } }
@GET @Path("/pets") @ApiOperation(value = "Get all pets.", response = PetListResponse.class) public Response<List<Pet>> getPets() { ... }
我想你可能正在寻找这样的东西:
@GET @Path("/pets") @ApiOperation(value = "Get all pets.", response = Pet.class) public Response<List<Pet>> getPets() { ... }
2 回答
围绕这个老问题,因为我正在为同一个问题寻找解决方案 . 这是我的解决方法:
我想你可能正在寻找这样的东西: