Hi,
we try to extract a proper REST API docu from the following model (shown below). All Rest classes inherit their default GET function from an abstract class.
Swagger-UI shows the available resources properly (in the example below, both GET), but the one, inherited from REST.get, the "wrong" Model (ie ModelJson) is shown. This makes absolutely sense because the ApiResponses annotation on REST.get identifies ModelJson as the response class.
However, we'd like the concrete class to show up in our swagger documentation, not the base class. It probably would be possible to override "get" in AnyRest and adapt the annotation. But this is not an option.
Can this issue be addressed with Swagger? And if yes, how?
Thanks in advance.
abstract class ModelJson {
int id;
Date createdOn;
...
}
class AnyJson extends ModelJson {
String anyString;
...
}
abstract class REST<T extends ModelJson> {
@GET
@Path("/{id: [0-9]*}")
@ApiOperation(value = "get resource", notes = "Gets a single resource from this endpoint.")
@ApiResponses(value = {@ApiResponse(code = HttpServletResponse.SC_OK, message = "OK.", response=ModelJson.class)}
T get(int id){...};
}
@Path("/any")
@Api(value = "any", description = "Does somthing fancy")
class AnyRest extends REST<AnyJson> {
@GET
@ApiOperation(value = "Do any action", notes = "this does anything")
@ApiResponses(value = {@ApiResponse(code = HttpServletResponse.SC_OK, message = "OK.", response=AnyJson.class)}
AnyJson anyFunction(...,...,...){
...
}
}