I am trying to document the response model using @ApiOperation(value = "",notes = "", response = XXX.class) following the example in petstore. Some of the response classes are ignored and not displayed, some of them are displayed. I specify the same response class in multiple resources and it got picked up only once by one resource. I tried adding httpMethod property in case the method is not picked up, but it did not help.
I am trying to understand what the issue could be, and how to troubleshoot it.
Thank you.
Here is a code example:
//The response class is not displayed at all for this resource
@GET
@Path("/{groupId}")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation( value = "",notes = "", response = UserGroupResults.class)
public Response getUserGroup(
.......
//******************************
//But it gets displayed properly by this one
@POST
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_FORM_URLENCODED})
@ApiOperation( value = "",notes = "", response = UserGroupResults.class)
public Response createUserGroup(
......
// and the response looks like this. The only not correct thing here is (Status 200). POST returns 201:
Response Class (Status 200)
Model
UserGroup {
id (string, optional),
name (string, optional),
description (string, optional),
email (string, optional)
}
//*************************
@ApiModel( value = "UserGroup" )
@XmlRootElement(name = "UserGroupResults")
public class UserGroupResults {
private String id;
private String name;
private String email;
private String description;
/**
*
* @param name
*/
public void setName(String name) {
}
/**
*
* @return name
*/
@XmlElement(name = "name")
public String getName() {
}
/**
*
* @param email
*/
public void setEmail(String email) {
this.email = ( email == null ? "" : email );
}
/**
*
* @return email
*/
@XmlElement(name = "email")
public String getEmail() {
return this.email;
}
/**
*
* @param description
*/
public void setDescription(String description) {
this.description = ( description == null ? "" : description );
}
/**
*
* @return description
*/
@XmlElement(name = "description")
public String getDescription() {
return this.description;
}
/**
* Getter for UserGroup's id.
* @return
*/
@XmlElement(name = "id")
public String getId() {
return id;
}
/**
* Setter for UserGroup's id.
* @param id
*/
public void setId(String id) {
}
}
/****************************************
We are using jersey 2.1 and javax-rs to build our REST API in JAVA. We use swagger 2.0 to document it.
These are the libraries from swagger we use to compile, just in case if they create the problem:
swagger-annotations-1.5.0.jar
swagger-jersey2-jaxrs-1.5.0.jar
swagger-core-1.5.0.jar
reflections-0.9.9.jar
guava-15.0.jar
json4s-core_2.10-3.2.11.jar
json4s-ast_2.10-3.2.11.jar
json4s-ext_2.10-3.2.11.jar
json4s-native_2.10-3.2.11.jar
json4s-jackson_2.10-3.2.11.jar
jackson-core-2.4.2.jar
jackson-databind-2.4.2.jar
jackson-annotations-2.4.2.jar
swagger-models-1.5.0.jar
slf4j-api-1.6.3.jar
commons-lang3-3.2.1.jar