Open jhogervorst opened 5 months ago
I think the generated switch should include a case 204 to handle this situation properly?
yes, would you have time to contribute a PR to fix it? I can show you some good starting points.
we also have a php-nextgen
client generator with some improvements and refactoring that you can give it a try (my guess is that likely multi response code is not yet handled)
we also have a
php-nextgen
client generator with some improvements and refactoring that you can give it a try (my guess is that likely multi response code is not yet handled)
@wing328 That's interesting! Didn't know about it. Where can I read more about it? Like, is it stable, or still in development/beta phase?
I think the generated switch should include a case 204 to handle this situation properly?
yes, would you have time to contribute a PR to fix it? I can show you some good starting points.
Yes, we could take a look at it, either for the php-nextgen
version or the 'old' one. Some starting points would be great, since we're not familiar with the code of the generator itself.
FYI, this issue is also present in php-nextgen. It runs json_decode on the empty response even if http status code is 204, which results in an exception
Bug Report Checklist
Description
When I have a path that can either return a 200 response (with some JSON body) or a 204 response (with no content), an exception is thrown when the 204 response is received by the generated PHP API client, even though it's a valid (according to my API schema) and successful response.
openapi-generator version
7.7.0 (latest)
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
Call the patch method on the generated API client, while getting a 204 response:
Expected output
I would expect this to return without errors, since the 204 response is valid (according to my API schema) and successful (HTTP
Actual output
Related issues/PRs
https://github.com/OpenAPITools/openapi-generator/issues/125
Suggest a fix
The problem seems that the generated
switch
statement only contains acase 200
(for the 200 response). The 204 response is not handled here.As a result, later code tries to parse the response as JSON, but that causes an exception, since the response is empty (which is expected for 204).
I think the generated
switch
should include acase 204
to handle this situation properly?