2

I have an application for my REST APIs using jersey (version 1.17). I am trying to set up swagger to document the same using swagger-maven-plugin (version 2.2)

Swagger documentation suggests:

In JAX-RS applications, the return type of the method would automatically be used, unless it is {@code javax.ws.rs.core.Response}.In that case, the operation return type would default to void as the actual response type cannot be known.

I am using a custom object (not javax.ws.rs.core.Response) as my method return type. But the response type remains void unless I specify it as part of the ApiOperation annotation.

@GET
@Produces({MediaType.APPLICATION_JSON})
@ApiOperation(
    value = "Description",
    response = MyCustomResponse.class
)
public MyCustomResponse myApiMethod() {
    return apiResponse;
}

I want to remove the response value from the annotation. What am I doing wrong here?

1
  • Probably a bit too late, but... Can you share what MyCustomResponse is? Specifically, does it inherit from javax.ws.rs.core.Response? Or is it just a regular DTO?
    – MatanRubin
    Feb 8, 2017 at 10:04

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.