-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
[ruby] Make File Downloads Threadsafe #16876
[ruby] Make File Downloads Threadsafe #16876
Conversation
please update the samples so that the CI can verify the change: https://github.com/OpenAPITools/openapi-generator/actions/runs/6577707103/job/17937746453?pr=16876 let me know if you need any help. |
the change looks good. about testing the file download, can you please PM me via Slack when you've time? |
circleci failure not related to this change |
Since this MR, file downloading doesn't work anymore without patching the generated The problem is an exception because of missing parameters, e.g.: ...
if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
data = deserialize_file(stream)
elsif opts[:return_type]
... Which should be ...
if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
data = deserialize_file(response, stream)
elsif opts[:return_type]
... and def call_api(http_method, path, opts = {})
stream = nil
begin
response = connection(opts).public_send(http_method.to_sym.downcase) do |req|
build_request(http_method, path, req, opts)
stream = download_file(request) if opts[:return_type] == 'File' || opts[:return_type] == 'Binary'
end
... Where the call to Obviously, file downloading hasn't been tested at all. |
can you please file a PR with the suggested fix? we can add a test in the echo API client to ensure the file download works as expected. PM me via Slack if you need the details. |
FYI https://github.com/OpenAPITools/openapi-generator/blob/master/samples/client/echo_api/python/test/test_manual.py#L110 is how we test it in the Python Echo API client. We need to add a similar test for the Ruby client. |
In MR OpenAPITools#16876, a bug was introduced that causes file downloading to fail for the Faraday adapter. This commit fixes the obvious missing parameter for the method call to download_file() and the missing variable `request` for saving the response value of the call to build_request(). Signed-off-by: Daniel Schnell <dschnell@grammatek.com>
Well, in fact we would need to add 3 such tests for each of the supported clients (Faraday, Typhoeus, httpx). There is a httpx client, but it misses the manual tests you mentioned. |
* Ruby Client for Faraday: fix file downloading In MR #16876, a bug was introduced that causes file downloading to fail for the Faraday adapter. This commit fixes the obvious missing parameter for the method call to download_file() and the missing variable `request` for saving the response value of the call to build_request(). Signed-off-by: Daniel Schnell <dschnell@grammatek.com> * Add automatically generated changes. --------- Signed-off-by: Daniel Schnell <dschnell@grammatek.com>
#16796
This makes the ApiClient threadsafe in ruby. I definitely need help testing this and following the process.
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
(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)