mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-03 06:00:52 +00:00
Rationalize response status code check. Ensure that all bona fide 2xx responses are treated in the same way that "200 OK" is.
Previously, was explicitly checking for response code 200 (ClientResponse.Status.OK). Now, checks the family of the response to make sure it is successful (Family.SUCCESSFUL). This enables us to POST to resources that return 201 created - without having to handle a checked ApiException.
This commit is contained in:
parent
59da358eb5
commit
c779905163
@ -12,6 +12,7 @@ import com.sun.jersey.api.client.config.DefaultClientConfig;
|
|||||||
import com.sun.jersey.api.client.filter.LoggingFilter;
|
import com.sun.jersey.api.client.filter.LoggingFilter;
|
||||||
import com.sun.jersey.api.client.WebResource.Builder;
|
import com.sun.jersey.api.client.WebResource.Builder;
|
||||||
|
|
||||||
|
import javax.ws.rs.core.Response.Status.Family;
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -123,7 +124,7 @@ public class ApiInvoker {
|
|||||||
else {
|
else {
|
||||||
throw new ApiException(500, "unknown method type " + method);
|
throw new ApiException(500, "unknown method type " + method);
|
||||||
}
|
}
|
||||||
if(response.getClientResponseStatus() == ClientResponse.Status.OK) {
|
if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
|
||||||
return (String) response.getEntity(String.class);
|
return (String) response.getEntity(String.class);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user