sdaschner / jaxrs-analyzer

Creates REST documentation for JAX-RS projects
Apache License 2.0
319 stars 101 forks source link

Support for javax.ws.rs Exceptions #126

Open edvasqueza opened 7 years ago

edvasqueza commented 7 years ago

Hello, I noticed that javax.ws.rs Exceptions are not considered by the analyzer. For example this code:

@POST
@Path("/enrollment")
public Response enrollment(@Valid Enrollment request) {
    if (userService.enrollment(request)) {
        return Response.noContent().build();
    } else {
        throw new javax.ws.rs.BadRequestException("Bad request");
    }
}

generates:

POST koath/internal/enrollment:
 Request:
  Content-Type: application/json
  Request Body: cl.kunder.koath.rest.requests.Enrollment
   application/json: {"id":"string","hash":"string"}

 Response:
  Content-Type: application/json
  Status Codes: 204

It should have added: Status Codes: 400

My actual code has the exception inside the enrollment method, but same result.

Also consider exceptions that extend javax.ws.rs exceptions.

sdaschner commented 7 years ago

Yes, this is due to how the analysis currently works. It takes the control flow into account, but not exception flows.