Skip to content

[Go-client] Fix inability to download files #9714

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

Closed

Conversation

icubbon
Copy link
Contributor

@icubbon icubbon commented Jun 7, 2021

Revert a change to the Go Client code that broke the ability to download files. This reverts the change made during the switch go-experimental
from 14d4131

Fix for #8039
The decoding for type file had been removed when the generator was switched to go-experimental
Re-added the code that existed in the 4.x release to handle downloading a file.

Tested by generating the pet-store examples to ensure that the previous code for downloading a file was present.
Generated an internal Go Rest API client that downloads a file from a Rest API. Then downloaded a file successfully.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvn clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@antihax @grokify @kemokemo @jirikuncar @ph4r5h4d

aeneasr and others added 22 commits April 6, 2021 17:14
Improves the way pass-by-value and pass-by-reference variables are used.

Closes OpenAPITools#8489
If polymorphism without discriminator was used, the previous code was unable to properly decode the vaules. By using a strict decoder, which rejects unknown fields, type guessing now works.
the ability to download files. This reverts the change
from OpenAPITools@14d4131
@wing328 wing328 added this to the 5.2.0 milestone Jun 15, 2021
@@ -419,6 +419,15 @@ func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err err
*s = string(b)
return nil
}
if f, ok := v.(**os.File); ok {
*f, err = ioutil.TempFile("", "HttpClientFile")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the following errors when testing the petstore go client:

go-petstore/client.go:391:13: undefined: ioutil

Can you please take a look when you've time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that. That is my mistake for missing that as my dev environment will do auto-imports that hid this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you merge another PR into your PR.

Can you file a PR with just the fix for downloading the files?

@wing328
Copy link
Member

wing328 commented Jun 19, 2021

I've cherry-pick your commits and filed #9812 instead. Closing this one.

@wing328 wing328 closed this Jun 19, 2021
@icubbon icubbon deleted the go-client-download-file-fix branch August 5, 2022 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants