Skip to content
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -915,17 +915,23 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
*
* @param contentTypes The Content-Type array to select from
* @return The Content-Type header to use. If the given array is empty,
* JSON will be used.
* returns null. If it matches "any", JSON will be used.
*/
public String selectHeaderContentType(String[] contentTypes) {
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];
}

Expand Down Expand Up @@ -955,7 +961,9 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
*/
public Entity<?> serialize(Object obj, Map<String, Object> formParams, String contentType, boolean isBodyNullable) throws ApiException {
Entity<?> entity;
if (contentType.startsWith("multipart/form-data")) {
if (contentType == null) {
return null;
} else if (contentType.startsWith("multipart/form-data")) {
MultiPart multiPart = new MultiPart();
for (Entry<String, Object> param: formParams.entrySet()) {
if (param.getValue() instanceof File) {
Expand Down Expand Up @@ -1000,12 +1008,15 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
*
* @param obj Object
* @param formParams Form parameters
* @param contentType Context type
* @param contentType Content type
* @param isBodyNullable True if the body is nullable
* @return String
* @throws ApiException API exception
*/
public String serializeToString(Object obj, Map<String, Object> formParams, String contentType, boolean isBodyNullable) throws ApiException {
if (contentType == null) {
return null;
}
try {
if (contentType.startsWith("multipart/form-data")) {
throw new ApiException("multipart/form-data not yet supported for serializeToString (http signature authentication)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,17 +831,23 @@ public String selectHeaderAccept(String[] accepts) {
*
* @param contentTypes The Content-Type array to select from
* @return The Content-Type header to use. If the given array is empty,
* JSON will be used.
* returns null. If it matches "any", JSON will be used.
*/
public String selectHeaderContentType(String[] contentTypes) {
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];
}

Expand Down Expand Up @@ -871,7 +877,9 @@ public String escapeString(String str) {
*/
public Entity<?> serialize(Object obj, Map<String, Object> formParams, String contentType, boolean isBodyNullable) throws ApiException {
Entity<?> entity;
if (contentType.startsWith("multipart/form-data")) {
if (contentType == null) {
return null;
} else if (contentType.startsWith("multipart/form-data")) {
MultiPart multiPart = new MultiPart();
for (Entry<String, Object> param: formParams.entrySet()) {
if (param.getValue() instanceof File) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -831,17 +831,23 @@ public String selectHeaderAccept(String[] accepts) {
*
* @param contentTypes The Content-Type array to select from
* @return The Content-Type header to use. If the given array is empty,
* JSON will be used.
* returns null. If it matches "any", JSON will be used.
*/
public String selectHeaderContentType(String[] contentTypes) {
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];
}

Expand Down Expand Up @@ -871,7 +877,9 @@ public String escapeString(String str) {
*/
public Entity<?> serialize(Object obj, Map<String, Object> formParams, String contentType, boolean isBodyNullable) throws ApiException {
Entity<?> entity;
if (contentType.startsWith("multipart/form-data")) {
if (contentType == null) {
return null;
} else if (contentType.startsWith("multipart/form-data")) {
MultiPart multiPart = new MultiPart();
for (Entry<String, Object> param: formParams.entrySet()) {
if (param.getValue() instanceof File) {
Expand Down Expand Up @@ -916,12 +924,15 @@ public Entity<?> serialize(Object obj, Map<String, Object> formParams, String co
*
* @param obj Object
* @param formParams Form parameters
* @param contentType Context type
* @param contentType Content type
* @param isBodyNullable True if the body is nullable
* @return String
* @throws ApiException API exception
*/
public String serializeToString(Object obj, Map<String, Object> formParams, String contentType, boolean isBodyNullable) throws ApiException {
if (contentType == null) {
return null;
}
try {
if (contentType.startsWith("multipart/form-data")) {
throw new ApiException("multipart/form-data not yet supported for serializeToString (http signature authentication)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void testSelectHeaderContentType() {
assertEquals("text/plain", apiClient.selectHeaderContentType(contentTypes));

contentTypes = new String[]{};
assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes));
assertNull(apiClient.selectHeaderContentType(contentTypes));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,17 +761,23 @@ public String selectHeaderAccept(String[] accepts) {
*
* @param contentTypes The Content-Type array to select from
* @return The Content-Type header to use. If the given array is empty,
* JSON will be used.
* returns null. If it matches "any", JSON will be used.
*/
public String selectHeaderContentType(String[] contentTypes) {
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];
}

Expand Down Expand Up @@ -801,7 +807,9 @@ public String escapeString(String str) {
*/
public Entity<?> serialize(Object obj, Map<String, Object> formParams, String contentType, boolean isBodyNullable) throws ApiException {
Entity<?> entity;
if (contentType.startsWith("multipart/form-data")) {
if (contentType == null) {
return null;
} else if (contentType.startsWith("multipart/form-data")) {
MultiPart multiPart = new MultiPart();
for (Entry<String, Object> param: formParams.entrySet()) {
if (param.getValue() instanceof File) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -706,17 +706,23 @@ public String selectHeaderAccept(String[] accepts) {
*
* @param contentTypes The Content-Type array to select from
* @return The Content-Type header to use. If the given array is empty,
* JSON will be used.
* returns null. If it matches "any", JSON will be used.
*/
public String selectHeaderContentType(String[] contentTypes) {
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];
}

Expand Down Expand Up @@ -746,7 +752,9 @@ public String escapeString(String str) {
*/
public Entity<?> serialize(Object obj, Map<String, Object> formParams, String contentType, boolean isBodyNullable) throws ApiException {
Entity<?> entity;
if (contentType.startsWith("multipart/form-data")) {
if (contentType == null) {
return null;
} else if (contentType.startsWith("multipart/form-data")) {
MultiPart multiPart = new MultiPart();
for (Entry<String, Object> param: formParams.entrySet()) {
if (param.getValue() instanceof File) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -915,17 +915,23 @@ public String selectHeaderAccept(String[] accepts) {
*
* @param contentTypes The Content-Type array to select from
* @return The Content-Type header to use. If the given array is empty,
* JSON will be used.
* returns null. If it matches "any", JSON will be used.
*/
public String selectHeaderContentType(String[] contentTypes) {
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];
}

Expand Down Expand Up @@ -955,7 +961,9 @@ public String escapeString(String str) {
*/
public Entity<?> serialize(Object obj, Map<String, Object> formParams, String contentType, boolean isBodyNullable) throws ApiException {
Entity<?> entity;
if (contentType.startsWith("multipart/form-data")) {
if (contentType == null) {
return null;
} else if (contentType.startsWith("multipart/form-data")) {
MultiPart multiPart = new MultiPart();
for (Entry<String, Object> param: formParams.entrySet()) {
if (param.getValue() instanceof File) {
Expand Down