OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Go] File download returns nil
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
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.
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 generated Go client from the linked OpenAPI declaration using the provided openapi-generator command. Start at the generated client's client.decode and the file-download endpoint, checking how the return value is passed through. Done means the download writes the file and returns a non-nil file pointer instead of nil.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100