[BUG] [Go] File download returns nil
Created by: acranbury
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Have an OpenAPI v3 endpoint definition to download a file, when you create the client, and try to execute a download, you get a nil file pointer back.
openapi-generator version
master
OpenAPI declaration file content or url
https://gist.github.com/acranbury/0b2358548c7e45ab5cc2f857b964cd28
Generation Details
java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g go -i apicurio_test.yaml -o /var/tmp/apicurio_test
Related issues/PRs
This seems related to https://github.com/OpenAPITools/openapi-generator/issues/8392 where the file upload fails
Suggest a fix
The issue is that client.decode
expects a **os.File
to be passed in, but the return type of the file download endpoint is already **os.File
. The endpoint passes &localVarReturnValue
which ends up as a ***os.File
, so the file write never happens and nil
is returned.
It seems like the **os.File
return type of the endpoint is unnecessary, and could be reduced to just *os.File
, or decode
could expect a ***os.File
, although a triple pointer makes me shudder just a little.