You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@
6
6
[](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.openapitools%22%20AND%20a%3A%22openapi-generator%22)
[](https://join.slack.com/t/openapi-generator/shared_invite/zt-2uoef5v0g-XGwo8~2oJ3EoziDSO1CmdQ)
9
+
[](https://join.slack.com/t/openapi-generator/shared_invite/zt-2wmkn4s8g-n19PJ99Y6Vei74WMUIehQA)
10
10
[](https://twitter.com/oas_generator)
11
11
[](https://gitpod.io/#https://github.com/OpenAPITools/openapi-generator)
Copy file name to clipboardExpand all lines: docs/faq.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@ title: "FAQ: General"
5
5
6
6
## Do you have a chat room?
7
7
8
-
[](https://join.slack.com/t/openapi-generator/shared_invite/zt-2uoef5v0g-XGwo8~2oJ3EoziDSO1CmdQ)
8
+
[](https://join.slack.com/t/openapi-generator/shared_invite/zt-2wmkn4s8g-n19PJ99Y6Vei74WMUIehQA)
9
9
10
10
## What is the governance structure of the OpenAPI Generator project?
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/resources/Java/libraries/native/api.mustache
+34-10Lines changed: 34 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -271,22 +271,46 @@ public class {{classname}} {
271
271
}
272
272
{{/vendorExtensions.x-java-text-plain-string}}
273
273
{{^vendorExtensions.x-java-text-plain-string}}
274
-
return new ApiResponse<{{{returnType}}}{{^returnType}}Void{{/returnType}}>(
275
-
localVarResponse.statusCode(),
276
-
localVarResponse.headers().map(),
277
-
{{#returnType}}
278
-
localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference<{{{returnType}}}>() {}) // closes the InputStream
279
-
{{/returnType}}
280
-
{{^returnType}}
281
-
null
282
-
{{/returnType}}
274
+
{{#returnType}}
275
+
{{! Fix for https://github.com/OpenAPITools/openapi-generator/issues/13968 }}
276
+
{{! This part had a bugfix for an empty response in the past, but this part of that PR was reverted because it was not doing anything. }}
277
+
{{! Keep this documentation here, because the problem is not obvious. }}
278
+
{{! `InputStream.available()` was used, but that only works for inputstreams that are already in memory, it will not give the right result if it is a remote stream. We only work with remote streams here. }}
{{! The `available` method would work with a `PushbackInputStream`, because we could read 1 byte to check if it exists then push it back so Jackson can read it again. The issue with that is that it will also insert an ascii character for "head of input"and that will break Jackson as it does not handle special whitespace characters. }}
281
+
{{! A fix for that problem is to read it into a string and remove those characters, but if we need to read it before giving it to jackson to fix the string then just reading it into a string as is to do an emptiness check is the cleaner solution. }}
282
+
{{! We could also manipulate the inputstream to remove that bad character, but string manipulation is easier to read and this codepath is not asyncronus so we do not gain anything by reading the stream later. }}
283
+
{{! This fix does make it unsuitable for large amounts of data because `InputStream.readAllbytes` is not meant for it, but a syncronus client is already not the right tool for that.}}
284
+
if (localVarResponse.body() == null) {
285
+
return new ApiResponse<{{{returnType}}}>(
286
+
localVarResponse.statusCode(),
287
+
localVarResponse.headers().map(),
288
+
null
289
+
);
290
+
}
291
+
292
+
String responseBody = new String(localVarResponse.body().readAllBytes());
293
+
localVarResponse.body().close();
294
+
295
+
return new ApiResponse<{{{returnType}}}>(
296
+
localVarResponse.statusCode(),
297
+
localVarResponse.headers().map(),
298
+
responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference<{{{returnType}}}>() {})
0 commit comments