forked from loafle/openapi-generator-original
[Java][okhttp] remove default content-type in the request (#10769)
* remove default content-type in java okhttp client * update smaples * update tests
This commit is contained in:
@@ -758,17 +758,23 @@ public class ApiClient {
|
||||
*
|
||||
* @param contentTypes The Content-Type array to select from
|
||||
* @return The Content-Type header to use. If the given array is empty,
|
||||
* or matches "any", JSON will be used.
|
||||
* returns null. If it matches "any", JSON will be used.
|
||||
*/
|
||||
public String selectHeaderContentType(String[] contentTypes) {
|
||||
if (contentTypes.length == 0 || contentTypes[0].equals("*/*")) {
|
||||
if (contentTypes.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (contentTypes[0].equals("*/*")) {
|
||||
return "application/json";
|
||||
}
|
||||
|
||||
for (String contentType : contentTypes) {
|
||||
if (isJsonMime(contentType)) {
|
||||
return contentType;
|
||||
}
|
||||
}
|
||||
|
||||
return contentTypes[0];
|
||||
}
|
||||
|
||||
@@ -1131,11 +1137,6 @@ public class ApiClient {
|
||||
processCookieParams(cookieParams, reqBuilder);
|
||||
|
||||
String contentType = (String) headerParams.get("Content-Type");
|
||||
// ensuring a default content type
|
||||
if (contentType == null) {
|
||||
contentType = "application/json";
|
||||
}
|
||||
|
||||
RequestBody reqBody;
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
|
||||
@@ -91,7 +91,9 @@ public class PingApi {
|
||||
"application/json"
|
||||
};
|
||||
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
|
||||
localVarHeaderParams.put("Content-Type", localVarContentType);
|
||||
if (localVarHeaderParams != null) {
|
||||
localVarHeaderParams.put("Content-Type", localVarContentType);
|
||||
}
|
||||
|
||||
String[] localVarAuthNames = new String[] { };
|
||||
return localVarApiClient.buildCall(localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback);
|
||||
|
||||
Reference in New Issue
Block a user