Closed cbraun closed 11 years ago
This is a problem related to type erasure. Unfortunately, once a class is compiled, the generic type is removed. This leaves your ResponseEntity looking like ResponseEntity<List
@ApiOperation(value = "Put your value here", notes = "Put your notes here", httpMethod = "PUT", responseClass = "UserResponseDTO")
However, this will leave off the JSON for ResponseEntity. Another alternative might be creating your own ResponseEntity class that all your DTO objects extend. This way those fields will always be included in your DTO objects and Swagger will be able to correctly generate the JSON you are looking for. We might be able to come up with some more alternatives if none of those work.
All of my controllers use the Spring 3.2 way of rest service production. That is they return objects that are wrapped in ResponseEntity. For example:
@RequestMapping(method = RequestMethod.GET) public ResponseEntity<List> getUsers() {
...
}
so the doc output looks like:
......
[{"httpMethod":"GET","responseClass":"ResponseEntity","nickname":"getUser","parameters":[{"name":"name","paramType":"path","required":true,"allowMultiple":false,"dataType":"string"}]
...
Ideally the parser would be able to detect the generic being used here as
User.