Skip to content

Commit f483b8d

Browse files
committed
Merge pull request #1233 from geekerzp/ruby-apiclient
Fix issue that using temp_folder_path from ApiClient in ruby client
2 parents 349702a + 5d1e705 commit f483b8d

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

modules/swagger-codegen/src/main/resources/ruby/api_client.mustache

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ module {{moduleName}}
160160
# @see Configuration#temp_folder_path
161161
# @return [File] the file downloaded
162162
def download_file(response)
163-
tmp_file = Tempfile.new '', @temp_folder_path
163+
tmp_file = Tempfile.new '', Configuration.temp_folder_path
164164
content_disposition = response.headers['Content-Disposition']
165165
if content_disposition
166166
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
@@ -172,7 +172,8 @@ module {{moduleName}}
172172
tmp_file.close!
173173

174174
File.open(path, 'w') { |file| file.write(response.body) }
175-
logger.info "File written to #{path}. Please move the file to a proper folder for further processing and delete the temp afterwards"
175+
Configuration.logger.info "File written to #{path}. Please move the file to a proper "\
176+
"folder for further processing and delete the temp afterwards"
176177
File.new(path)
177178
end
178179

samples/client/petstore/ruby/lib/petstore/api_client.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def convert_to_type(data, return_type)
160160
# @see Configuration#temp_folder_path
161161
# @return [File] the file downloaded
162162
def download_file(response)
163-
tmp_file = Tempfile.new '', @temp_folder_path
163+
tmp_file = Tempfile.new '', Configuration.temp_folder_path
164164
content_disposition = response.headers['Content-Disposition']
165165
if content_disposition
166166
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
@@ -172,7 +172,8 @@ def download_file(response)
172172
tmp_file.close!
173173

174174
File.open(path, 'w') { |file| file.write(response.body) }
175-
logger.info "File written to #{path}. Please move the file to a proper folder for further processing and delete the temp afterwards"
175+
Configuration.logger.info "File written to #{path}. Please move the file to a proper "\
176+
"folder for further processing and delete the temp afterwards"
176177
File.new(path)
177178
end
178179

0 commit comments

Comments
 (0)