How to handle exceptions with Swagger?
<p>I am building some test APIs using swagger (1.5) and JAX-rs with Jersey (1.13) and I m trying to implement exception handling. For example I have the following code when receiving the results from my DB (Elasticsearch)</p>

<pre><code>@POST
@Path("/category")
@ApiOperation(value="returns products")
@Produces({ "application/json" })
public Response getPostCategories( 
        @ApiParam(value="keyphrase, required=true) @QueryParam("keyphrase") String keyphrase,
        @ApiParam(value="category) @QueryParam("category") String category,     
        @Context SecurityContext securityContext) 
throws WebApplicationException {        
    SearchRequest searchRequest = new SearchRequest();
    searchRequest.setKeyphrase(keyphrase);
    searchRequest.setCategory(category);

    SearchCategoryQuery categoryQuery = new SearchCategoryQuery();
    String searchResponse = null;
    try
    {           
        searchResponse = categoryQuery.searchCategory(searchRequest);
    }
    catch (WebApplicationException ex)
    {
        throw new WebApplicationException(Response.status(Status.BAD_REQUEST).entity("results no found").type(javax.ws.rs.core.MediaType.APPLICATION_JSON).build());
    }
    return Response.ok(searchResponse).build();
}
</code></pre>

<p>However, in the output swagger always prints the same response<a href="https://i.stack.imgur.com/EI1rZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EI1rZ.png" alt="enter image description here"></a></p>

<p>What I need instead is to receive the error messages I specify in each exception. Any ideas?</p>