Reputation: 11
I have a generic response object in my Dropwizard API with Response which is a wrapper containing a status enum and a value. The API operations have a reponse like Response or Response>.
I have been trying to find a way to handle this and saw some mentions that this is handled for Spring Rest / Swagger?
I am using: com.wordnik swagger-jaxrs_2.10 1.3.5
Has anyone resolved this in a nice generic way?
Upvotes: 1
Views: 908
Reputation: 421
Came around this old question as I was looking for a solution for the same issue. Here is my workaround :
Create a wrapper class :
@ApiModel
public class PetListResponse extends Response<List<Pet>> {
@Override
@ApiModelProperty
public List<Pet> getValue() {
return super.getValue()
}
}
Override the response in the API :
@GET
@Path("/pets")
@ApiOperation(value = "Get all pets.", response = PetListResponse.class)
public Response<List<Pet>> getPets() {
...
}
Success :)
Upvotes: 0
Reputation: 10962
I think you might be looking for something like this:
@GET
@Path("/pets")
@ApiOperation(value = "Get all pets.", response = Pet.class)
public Response<List<Pet>> getPets() {
...
}
Upvotes: 1