OpenAPITools / OpenAPITools/openapi-generator
[BUG] Incorrect handling of octet stream for java 11 native
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
If the type of the response is not JSON or primitive type but octet-stream, then the generated code handles it incorrectly.
The generated code will treat "File" as any other type and try to convert it.
HttpResponse<InputStream> localVarResponse = memberVarHttpClient.send(
localVarRequestBuilder.build(),
HttpResponse.BodyHandlers.ofInputStream());
if (localVarResponse.statusCode()/ 100 != 2) {
throw new ApiException(localVarResponse.statusCode(),
"filesUuidDownloadGet call received non-success response",
localVarResponse.headers(),
localVarResponse.body() == null ? null : new String(localVarResponse.body().readAllBytes()));
}
openapi-generator version
4.1.0
Suggest a fix
The file or input stream should be passed as input parameter to where the respose should be written.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the Java 11 native client generation for an octet-stream response and inspect the generated response-handling code shown in the issue. Confirm that the completed behavior passes the file or input stream to the requested output destination instead of treating File as a value to convert.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100