mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 22:50:53 +00:00
Support primitive string response in Java clients
This commit is contained in:
parent
69f8274287
commit
44bbe301cb
@ -385,8 +385,15 @@ public class ApiClient {
|
|||||||
|
|
||||||
if (contentType.startsWith("application/json")) {
|
if (contentType.startsWith("application/json")) {
|
||||||
return json.deserialize(body, returnType);
|
return json.deserialize(body, returnType);
|
||||||
|
} else if (returnType.getType().equals(String.class)) {
|
||||||
|
// Expecting string, return the raw response body.
|
||||||
|
return (T) body;
|
||||||
} else {
|
} else {
|
||||||
throw new ApiException(500, "can not deserialize Content-Type: " + contentType);
|
throw new ApiException(
|
||||||
|
500,
|
||||||
|
"Content type \"" + contentType + "\" is not supported for type: "
|
||||||
|
+ returnType.getType()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -389,8 +389,15 @@ public class ApiClient {
|
|||||||
|
|
||||||
if (contentType.startsWith("application/json")) {
|
if (contentType.startsWith("application/json")) {
|
||||||
return json.deserialize(body, returnType);
|
return json.deserialize(body, returnType);
|
||||||
|
} else if (returnType.getType().equals(String.class)) {
|
||||||
|
// Expecting string, return the raw response body.
|
||||||
|
return (T) body;
|
||||||
} else {
|
} else {
|
||||||
throw new ApiException(500, "can not deserialize Content-Type: " + contentType);
|
throw new ApiException(
|
||||||
|
500,
|
||||||
|
"Content type \"" + contentType + "\" is not supported for type: "
|
||||||
|
+ returnType.getType()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -429,7 +436,7 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Invocation.Builder invocationBuilder = target.request(contentType).accept(accept);
|
Invocation.Builder invocationBuilder = target.request().accept(accept);
|
||||||
|
|
||||||
for (String key : headerParams.keySet()) {
|
for (String key : headerParams.keySet()) {
|
||||||
String value = headerParams.get(key);
|
String value = headerParams.get(key);
|
||||||
|
@ -536,9 +536,12 @@ public class ApiClient {
|
|||||||
}
|
}
|
||||||
if (contentType.startsWith("application/json")) {
|
if (contentType.startsWith("application/json")) {
|
||||||
return json.deserialize(respBody, returnType);
|
return json.deserialize(respBody, returnType);
|
||||||
|
} else if (returnType.equals(String.class)) {
|
||||||
|
// Expecting string, return the raw response body.
|
||||||
|
return (T) respBody;
|
||||||
} else {
|
} else {
|
||||||
throw new ApiException(
|
throw new ApiException(
|
||||||
"Content type \"" + contentType + "\" is not supported",
|
"Content type \"" + contentType + "\" is not supported for type: " + returnType,
|
||||||
response.code(),
|
response.code(),
|
||||||
response.headers().toMultimap(),
|
response.headers().toMultimap(),
|
||||||
respBody);
|
respBody);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user