-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[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
Conversation
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
@@ -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") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
I've cherry-pick your commits and filed #9812 instead. Closing this one. |
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 togo-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
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.
master
,5.1.x
,6.0.x
@antihax @grokify @kemokemo @jirikuncar @ph4r5h4d