Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] [Go] File download returns nil #11965

Open
5 of 6 tasks
acranbury opened this issue Mar 24, 2022 · 1 comment
Open
5 of 6 tasks

[BUG] [Go] File download returns nil #11965

acranbury opened this issue Mar 24, 2022 · 1 comment

Comments

@acranbury
Copy link

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 #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.

@KevLohmann
Copy link

I'm having the same issue. Any recommendation apart from editing generated code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants