Skip to content

Commit a284bb7

Browse files
committed
Rebuild Java clients of the Petstore sample
1 parent 44bbe30 commit a284bb7

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

samples/client/petstore/java/default/src/main/java/io/swagger/client/ApiClient.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import io.swagger.client.auth.ApiKeyAuth;
4040
import io.swagger.client.auth.OAuth;
4141

42-
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:58.351+08:00")
42+
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-23T12:52:56.012+08:00")
4343
public class ApiClient {
4444
private Map<String, Client> hostMap = new HashMap<String, Client>();
4545
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
@@ -384,8 +384,15 @@ public <T> T deserialize(ClientResponse response, TypeRef returnType) throws Api
384384

385385
if (contentType.startsWith("application/json")) {
386386
return json.deserialize(body, returnType);
387+
} else if (returnType.getType().equals(String.class)) {
388+
// Expecting string, return the raw response body.
389+
return (T) body;
387390
} else {
388-
throw new ApiException(500, "can not deserialize Content-Type: " + contentType);
391+
throw new ApiException(
392+
500,
393+
"Content type \"" + contentType + "\" is not supported for type: "
394+
+ returnType.getType()
395+
);
389396
}
390397
}
391398

samples/client/petstore/java/jersey2/src/main/java/io/swagger/client/ApiClient.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import io.swagger.client.auth.ApiKeyAuth;
4444
import io.swagger.client.auth.OAuth;
4545

46-
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-11T11:35:51.678+08:00")
46+
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-09-23T12:52:46.364+08:00")
4747
public class ApiClient {
4848
private Map<String, Client> hostMap = new HashMap<String, Client>();
4949
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
@@ -388,8 +388,15 @@ public <T> T deserialize(Response response, TypeRef returnType) throws ApiExcept
388388

389389
if (contentType.startsWith("application/json")) {
390390
return json.deserialize(body, returnType);
391+
} else if (returnType.getType().equals(String.class)) {
392+
// Expecting string, return the raw response body.
393+
return (T) body;
391394
} else {
392-
throw new ApiException(500, "can not deserialize Content-Type: " + contentType);
395+
throw new ApiException(
396+
500,
397+
"Content type \"" + contentType + "\" is not supported for type: "
398+
+ returnType.getType()
399+
);
393400
}
394401
}
395402

@@ -428,7 +435,7 @@ public <T> T invokeAPI(String path, String method, List<Pair> queryParams, Objec
428435
}
429436
}
430437

431-
Invocation.Builder invocationBuilder = target.request(contentType).accept(accept);
438+
Invocation.Builder invocationBuilder = target.request().accept(accept);
432439

433440
for (String key : headerParams.keySet()) {
434441
String value = headerParams.get(key);

samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/ApiClient.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -535,9 +535,12 @@ public <T> T deserialize(Response response, Type returnType) throws ApiException
535535
}
536536
if (contentType.startsWith("application/json")) {
537537
return json.deserialize(respBody, returnType);
538+
} else if (returnType.equals(String.class)) {
539+
// Expecting string, return the raw response body.
540+
return (T) respBody;
538541
} else {
539542
throw new ApiException(
540-
"Content type \"" + contentType + "\" is not supported",
543+
"Content type \"" + contentType + "\" is not supported for type: " + returnType,
541544
response.code(),
542545
response.headers().toMultimap(),
543546
respBody);

0 commit comments

Comments
 (0)