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
[] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I am using the openapi-generator-cli to generate java code. The generated code throws an assertion error while attempting to deserialize an empty response body coming from a 500 response.
openapi-generator version
7.8.0
OpenAPI declaration file content or url
Generated code will call getApiException when server returns a 500:
The response.body() is not null so the code will attempt to read the bytes of an empty response and trigger an assertion in the underlying int read(byte[] bytes, int off, int len) method:
public int read(byte[] bytes, int off, int len) throws IOException {
...
assert read > 0 && read <= buffer.remaining();
...
}
Bug Report Checklist
Description
I am using the
openapi-generator-cli
to generate java code. The generated code throws an assertion error while attempting to deserialize an empty response body coming from a500
response.openapi-generator version
7.8.0
OpenAPI declaration file content or url
Generated code will call
getApiException
when server returns a500
:The generated code for
getApiException
is the following:The
response.body()
is not null so the code will attempt to read the bytes of an empty response and trigger an assertion in the underlyingint read(byte[] bytes, int off, int len)
method:Generation Details
openapi-generator-cli generate --generator-key=client-java
Steps to reproduce
Create an endpoint that trhows a 500 with a empty body response.
Related issues/PRs
N/A
Suggest a fix
Do not attempt to deserialize the bytes if the response is null not null but empty.
The text was updated successfully, but these errors were encountered: