Reputation: 5318
Here's a delete endpoint:
@ApiOperation(value = "delete subscription")
@ApiResponses(value = {
@ApiResponse(code = 204, message = "Deleted", response = Void.class),
@ApiResponse(code = 404, message = "Not Found")
})
@DeleteMapping("/{id}")
@ResponseStatus(HttpStatus.NO_CONTENT)
public ListenableFuture<ResponseEntity<Void>> delete(@PathVariable long id)
Springfox generates an API spec with a response body:
{
"cancelled": true,
"done": true
}
Obviously I want the response body spec to be blank for 204. How to achieve this?
N.B. if I change the endpoint be synchronous:
public void delete(@PathVariable long id)
then the generated API is fine.
Upvotes: 4
Views: 4427
Reputation: 143
Try adding
.genericModelSubstitutes(ListenableFuture.class)
to your Docket configuration to support ListenableFuture<T>
.
Substitutes each generic class with it's direct parameterized type. genericModelSubstitutes(ResponseEntity.class) would substitute ResponseEntity<MyModel> with MyModel
For example:
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.genericModelSubstitutes(ListenableFuture.class);
Upvotes: 1