mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-06-29 04:00:51 +00:00
Support for multipart/form-data; charset="utf-8" in Java GSON Generator (#16211)
* Support for multipart/form-data; charset="utf-8" Previously, it was only checked for an exact equal string, which failed when there were additional options such as charset. * Update samples
This commit is contained in:
parent
7ca84e5c88
commit
adac3b127f
@ -1426,12 +1426,15 @@ public class ApiClient {
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
String contentType = headerParams.get("Content-Type");
|
||||
|
||||
String contentTypePure = contentType;
|
||||
if (contentTypePure != null && contentTypePure.contains(";")) {
|
||||
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
|
||||
}
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyFormEncoding(formParams);
|
||||
} else if ("multipart/form-data".equals(contentType)) {
|
||||
} else if ("multipart/form-data".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyMultipart(formParams);
|
||||
} else if (body == null) {
|
||||
if ("DELETE".equals(method)) {
|
||||
|
@ -1166,12 +1166,15 @@ public class ApiClient {
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
String contentType = headerParams.get("Content-Type");
|
||||
|
||||
String contentTypePure = contentType;
|
||||
if (contentTypePure != null && contentTypePure.contains(";")) {
|
||||
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
|
||||
}
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyFormEncoding(formParams);
|
||||
} else if ("multipart/form-data".equals(contentType)) {
|
||||
} else if ("multipart/form-data".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyMultipart(formParams);
|
||||
} else if (body == null) {
|
||||
if ("DELETE".equals(method)) {
|
||||
|
@ -1189,12 +1189,15 @@ public class ApiClient {
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
String contentType = headerParams.get("Content-Type");
|
||||
|
||||
String contentTypePure = contentType;
|
||||
if (contentTypePure != null && contentTypePure.contains(";")) {
|
||||
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
|
||||
}
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyFormEncoding(formParams);
|
||||
} else if ("multipart/form-data".equals(contentType)) {
|
||||
} else if ("multipart/form-data".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyMultipart(formParams);
|
||||
} else if (body == null) {
|
||||
if ("DELETE".equals(method)) {
|
||||
|
@ -1274,12 +1274,15 @@ public class ApiClient {
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
String contentType = headerParams.get("Content-Type");
|
||||
|
||||
String contentTypePure = contentType;
|
||||
if (contentTypePure != null && contentTypePure.contains(";")) {
|
||||
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
|
||||
}
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyFormEncoding(formParams);
|
||||
} else if ("multipart/form-data".equals(contentType)) {
|
||||
} else if ("multipart/form-data".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyMultipart(formParams);
|
||||
} else if (body == null) {
|
||||
if ("DELETE".equals(method)) {
|
||||
|
@ -1267,12 +1267,15 @@ public class ApiClient {
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
String contentType = headerParams.get("Content-Type");
|
||||
|
||||
String contentTypePure = contentType;
|
||||
if (contentTypePure != null && contentTypePure.contains(";")) {
|
||||
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
|
||||
}
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyFormEncoding(formParams);
|
||||
} else if ("multipart/form-data".equals(contentType)) {
|
||||
} else if ("multipart/form-data".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyMultipart(formParams);
|
||||
} else if (body == null) {
|
||||
if ("DELETE".equals(method)) {
|
||||
|
@ -1262,12 +1262,15 @@ public class ApiClient {
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
String contentType = headerParams.get("Content-Type");
|
||||
|
||||
String contentTypePure = contentType;
|
||||
if (contentTypePure != null && contentTypePure.contains(";")) {
|
||||
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
|
||||
}
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyFormEncoding(formParams);
|
||||
} else if ("multipart/form-data".equals(contentType)) {
|
||||
} else if ("multipart/form-data".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyMultipart(formParams);
|
||||
} else if (body == null) {
|
||||
if ("DELETE".equals(method)) {
|
||||
|
@ -1265,12 +1265,15 @@ public class ApiClient {
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
String contentType = headerParams.get("Content-Type");
|
||||
|
||||
String contentTypePure = contentType;
|
||||
if (contentTypePure != null && contentTypePure.contains(";")) {
|
||||
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
|
||||
}
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyFormEncoding(formParams);
|
||||
} else if ("multipart/form-data".equals(contentType)) {
|
||||
} else if ("multipart/form-data".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyMultipart(formParams);
|
||||
} else if (body == null) {
|
||||
if ("DELETE".equals(method)) {
|
||||
|
@ -1268,12 +1268,15 @@ public class ApiClient {
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
String contentType = headerParams.get("Content-Type");
|
||||
|
||||
String contentTypePure = contentType;
|
||||
if (contentTypePure != null && contentTypePure.contains(";")) {
|
||||
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
|
||||
}
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyFormEncoding(formParams);
|
||||
} else if ("multipart/form-data".equals(contentType)) {
|
||||
} else if ("multipart/form-data".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyMultipart(formParams);
|
||||
} else if (body == null) {
|
||||
if ("DELETE".equals(method)) {
|
||||
|
@ -1262,12 +1262,15 @@ public class ApiClient {
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
String contentType = headerParams.get("Content-Type");
|
||||
|
||||
String contentTypePure = contentType;
|
||||
if (contentTypePure != null && contentTypePure.contains(";")) {
|
||||
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
|
||||
}
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyFormEncoding(formParams);
|
||||
} else if ("multipart/form-data".equals(contentType)) {
|
||||
} else if ("multipart/form-data".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyMultipart(formParams);
|
||||
} else if (body == null) {
|
||||
if ("DELETE".equals(method)) {
|
||||
|
@ -1262,12 +1262,15 @@ public class ApiClient {
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
String contentType = headerParams.get("Content-Type");
|
||||
|
||||
String contentTypePure = contentType;
|
||||
if (contentTypePure != null && contentTypePure.contains(";")) {
|
||||
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
|
||||
}
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyFormEncoding(formParams);
|
||||
} else if ("multipart/form-data".equals(contentType)) {
|
||||
} else if ("multipart/form-data".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyMultipart(formParams);
|
||||
} else if (body == null) {
|
||||
if ("DELETE".equals(method)) {
|
||||
|
@ -1327,12 +1327,15 @@ public class ApiClient {
|
||||
// prepare HTTP request body
|
||||
RequestBody reqBody;
|
||||
String contentType = headerParams.get("Content-Type");
|
||||
|
||||
String contentTypePure = contentType;
|
||||
if (contentTypePure != null && contentTypePure.contains(";")) {
|
||||
contentTypePure = contentType.substring(0, contentType.indexOf(";"));
|
||||
}
|
||||
if (!HttpMethod.permitsRequestBody(method)) {
|
||||
reqBody = null;
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentType)) {
|
||||
} else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyFormEncoding(formParams);
|
||||
} else if ("multipart/form-data".equals(contentType)) {
|
||||
} else if ("multipart/form-data".equals(contentTypePure)) {
|
||||
reqBody = buildRequestBodyMultipart(formParams);
|
||||
} else if (body == null) {
|
||||
if ("DELETE".equals(method)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user