forked from loafle/openapi-generator-original
[JAVA][Webclient]fix select body for url encoded media type. (#2686)
* fix select body for url encoded media type. * run bin.
This commit is contained in:
parent
c797073858
commit
d6306d8fee
@ -472,8 +472,20 @@ public class ApiClient {
|
|||||||
* @return Object the selected body
|
* @return Object the selected body
|
||||||
*/
|
*/
|
||||||
protected BodyInserter<?, ? super ClientHttpRequest> selectBody(Object obj, MultiValueMap<String, Object> formParams, MediaType contentType) {
|
protected BodyInserter<?, ? super ClientHttpRequest> selectBody(Object obj, MultiValueMap<String, Object> formParams, MediaType contentType) {
|
||||||
boolean isForm = MediaType.MULTIPART_FORM_DATA.isCompatibleWith(contentType) || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(contentType);
|
if(MediaType.APPLICATION_FORM_URLENCODED.equals(contentType)) {
|
||||||
return isForm ? BodyInserters.fromMultipartData(formParams) : (obj != null ? BodyInserters.fromObject(obj) : null);
|
MultiValueMap<String, String> map = new LinkedMultiValueMap();
|
||||||
|
|
||||||
|
formParams
|
||||||
|
.toSingleValueMap()
|
||||||
|
.entrySet()
|
||||||
|
.forEach(es -> map.add(es.getKey(), (String) es.getValue()));
|
||||||
|
|
||||||
|
return BodyInserters.fromFormData(map);
|
||||||
|
} else if(MediaType.MULTIPART_FORM_DATA.equals(contentType)) {
|
||||||
|
return BodyInserters.fromMultipartData(formParams);
|
||||||
|
} else {
|
||||||
|
return obj != null ? BodyInserters.fromObject(obj) : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -468,8 +468,20 @@ public class ApiClient {
|
|||||||
* @return Object the selected body
|
* @return Object the selected body
|
||||||
*/
|
*/
|
||||||
protected BodyInserter<?, ? super ClientHttpRequest> selectBody(Object obj, MultiValueMap<String, Object> formParams, MediaType contentType) {
|
protected BodyInserter<?, ? super ClientHttpRequest> selectBody(Object obj, MultiValueMap<String, Object> formParams, MediaType contentType) {
|
||||||
boolean isForm = MediaType.MULTIPART_FORM_DATA.isCompatibleWith(contentType) || MediaType.APPLICATION_FORM_URLENCODED.isCompatibleWith(contentType);
|
if(MediaType.APPLICATION_FORM_URLENCODED.equals(contentType)) {
|
||||||
return isForm ? BodyInserters.fromMultipartData(formParams) : (obj != null ? BodyInserters.fromObject(obj) : null);
|
MultiValueMap<String, String> map = new LinkedMultiValueMap();
|
||||||
|
|
||||||
|
formParams
|
||||||
|
.toSingleValueMap()
|
||||||
|
.entrySet()
|
||||||
|
.forEach(es -> map.add(es.getKey(), (String) es.getValue()));
|
||||||
|
|
||||||
|
return BodyInserters.fromFormData(map);
|
||||||
|
} else if(MediaType.MULTIPART_FORM_DATA.equals(contentType)) {
|
||||||
|
return BodyInserters.fromMultipartData(formParams);
|
||||||
|
} else {
|
||||||
|
return obj != null ? BodyInserters.fromObject(obj) : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user