Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for header's Content-Type:"strategic merge patch" for patch operation's. #133

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions kubernetes/src/main/java/io/kubernetes/client/ApiClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -920,13 +920,19 @@ public Call buildCall(String path, String method, List<Pair> queryParams, List<P
* @throws ApiException If fail to serialize the request body object
*/
public Request buildRequest(String path, String method, List<Pair> queryParams, List<Pair> collectionQueryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams);
String contentType = (String) headerParams.get("Content-Type");
// Content-Type: JSON Patch( for json object) and Strategic Merge Patch (for list of json object)
if("application/json-patch+json".equals(contentType) && !List.class.isInstance(body)) {
contentType = "application/strategic-merge-patch+json";
headerParams.put("Content-Type", contentType);
}

updateParamsForAuth(authNames, queryParams, headerParams);

final String url = buildUrl(path, queryParams, collectionQueryParams);
final Request.Builder reqBuilder = new Request.Builder().url(url);
processHeaderParams(headerParams, reqBuilder);

String contentType = (String) headerParams.get("Content-Type");
// ensuring a default content type
if (contentType == null) {
contentType = "application/json";
Expand Down