forked from loafle/openapi-generator-original
[Java][Native] Fix an issue leading to an altered String parameter when consuming formatted strings like XML (#11640)
* Fix the generated request builder when using a string body parameter * Update the samples according to the fix for #11638
This commit is contained in:
parent
d6a97b0c39
commit
d45cb6511f
@ -346,12 +346,17 @@ public class {{classname}} {
|
||||
localVarRequestBuilder.header("Accept", "{{#hasProduces}}{{#produces}}{{mediaType}}{{^-last}}, {{/-last}}{{/produces}}{{/hasProduces}}{{#hasProduces}}{{^produces}}application/json{{/produces}}{{/hasProduces}}{{^hasProduces}}application/json{{/hasProduces}}");
|
||||
|
||||
{{#bodyParam}}
|
||||
{{#isString}}
|
||||
localVarRequestBuilder.method("{{httpMethod}}", HttpRequest.BodyPublishers.ofString({{paramName}}));
|
||||
{{/isString}}
|
||||
{{^isString}}
|
||||
try {
|
||||
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes({{paramName}});
|
||||
localVarRequestBuilder.method("{{httpMethod}}", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
{{/isString}}
|
||||
{{/bodyParam}}
|
||||
{{^bodyParam}}
|
||||
localVarRequestBuilder.method("{{httpMethod}}", HttpRequest.BodyPublishers.noBody());
|
||||
|
@ -519,12 +519,7 @@ public class FakeApi {
|
||||
localVarRequestBuilder.header("Content-Type", "application/json");
|
||||
localVarRequestBuilder.header("Accept", "*/*");
|
||||
|
||||
try {
|
||||
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body);
|
||||
localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofString(body));
|
||||
if (memberVarReadTimeout != null) {
|
||||
localVarRequestBuilder.timeout(memberVarReadTimeout);
|
||||
}
|
||||
|
@ -445,12 +445,7 @@ public class FakeApi {
|
||||
localVarRequestBuilder.header("Content-Type", "application/json");
|
||||
localVarRequestBuilder.header("Accept", "*/*");
|
||||
|
||||
try {
|
||||
byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(body);
|
||||
localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody));
|
||||
} catch (IOException e) {
|
||||
throw new ApiException(e);
|
||||
}
|
||||
localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofString(body));
|
||||
if (memberVarReadTimeout != null) {
|
||||
localVarRequestBuilder.timeout(memberVarReadTimeout);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user