File tree Expand file tree Collapse file tree
modules/openapi-generator/src/main/resources/ruby-client
echo_api/ruby-typhoeus/lib/openapi_client
ruby-autoload/lib/petstore
extensions/x-auth-id-alias/ruby-client/lib/x_auth_id_alias
dynamic-servers/ruby/lib/dynamic_servers
generate-alias-as-model/ruby-client/lib/petstore Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44 # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
55 def call_api(http_method, path, opts = { } )
66 request = build_request(http_method, path, opts)
7- tempfile = download_file(request) if opts[:return_type] == 'File'
7+ tempfile = nil
8+ (download_file(request) { tempfile = _1 } ) if opts[:return_type] == 'File'
89 response = request.run
910
1011 if @config.debugging
145146 chunk.force_encoding(encoding)
146147 tempfile.write(chunk)
147148 end
148- # run the request to ensure the tempfile is created successfully before returning it
149- request.run
150- if tempfile
149+ request.on_complete do
150+ if !tempfile
151+ fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{ request.inspect} ")
152+ end
151153 tempfile.close
152154 @config.logger.info "Temp file written to #{ tempfile.path} , please copy the file to a proper folder "\
153155 "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
154156 "will be deleted automatically with GC. It's also recommended to delete the temp file "\
155157 "explicitly with `tempfile.delete`"
156- else
157- fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{ request.inspect} ")
158+ yield tempfile if block_given?
158159 end
159-
160- tempfile
161160 end
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ def self.default
4949 # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
5050 def call_api ( http_method , path , opts = { } )
5151 request = build_request ( http_method , path , opts )
52- tempfile = download_file ( request ) if opts [ :return_type ] == 'File'
52+ tempfile = nil
53+ ( download_file ( request ) { tempfile = _1 } ) if opts [ :return_type ] == 'File'
5354 response = request . run
5455
5556 if @config . debugging
@@ -188,19 +189,17 @@ def download_file(request)
188189 chunk . force_encoding ( encoding )
189190 tempfile . write ( chunk )
190191 end
191- # run the request to ensure the tempfile is created successfully before returning it
192- request . run
193- if tempfile
192+ request . on_complete do
193+ if !tempfile
194+ fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
195+ end
194196 tempfile . close
195197 @config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
196198 "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
197199 "will be deleted automatically with GC. It's also recommended to delete the temp file " \
198200 "explicitly with `tempfile.delete`"
199- else
200- fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
201+ yield tempfile if block_given?
201202 end
202-
203- tempfile
204203 end
205204
206205 # Check if the given MIME is a JSON MIME.
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ def self.default
4949 # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
5050 def call_api ( http_method , path , opts = { } )
5151 request = build_request ( http_method , path , opts )
52- tempfile = download_file ( request ) if opts [ :return_type ] == 'File'
52+ tempfile = nil
53+ ( download_file ( request ) { tempfile = _1 } ) if opts [ :return_type ] == 'File'
5354 response = request . run
5455
5556 if @config . debugging
@@ -188,19 +189,17 @@ def download_file(request)
188189 chunk . force_encoding ( encoding )
189190 tempfile . write ( chunk )
190191 end
191- # run the request to ensure the tempfile is created successfully before returning it
192- request . run
193- if tempfile
192+ request . on_complete do
193+ if !tempfile
194+ fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
195+ end
194196 tempfile . close
195197 @config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
196198 "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
197199 "will be deleted automatically with GC. It's also recommended to delete the temp file " \
198200 "explicitly with `tempfile.delete`"
199- else
200- fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
201+ yield tempfile if block_given?
201202 end
202-
203- tempfile
204203 end
205204
206205 # Check if the given MIME is a JSON MIME.
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ def self.default
4949 # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
5050 def call_api ( http_method , path , opts = { } )
5151 request = build_request ( http_method , path , opts )
52- tempfile = download_file ( request ) if opts [ :return_type ] == 'File'
52+ tempfile = nil
53+ ( download_file ( request ) { tempfile = _1 } ) if opts [ :return_type ] == 'File'
5354 response = request . run
5455
5556 if @config . debugging
@@ -188,19 +189,17 @@ def download_file(request)
188189 chunk . force_encoding ( encoding )
189190 tempfile . write ( chunk )
190191 end
191- # run the request to ensure the tempfile is created successfully before returning it
192- request . run
193- if tempfile
192+ request . on_complete do
193+ if !tempfile
194+ fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
195+ end
194196 tempfile . close
195197 @config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
196198 "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
197199 "will be deleted automatically with GC. It's also recommended to delete the temp file " \
198200 "explicitly with `tempfile.delete`"
199- else
200- fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
201+ yield tempfile if block_given?
201202 end
202-
203- tempfile
204203 end
205204
206205 # Check if the given MIME is a JSON MIME.
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ def self.default
4949 # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
5050 def call_api ( http_method , path , opts = { } )
5151 request = build_request ( http_method , path , opts )
52- tempfile = download_file ( request ) if opts [ :return_type ] == 'File'
52+ tempfile = nil
53+ ( download_file ( request ) { tempfile = _1 } ) if opts [ :return_type ] == 'File'
5354 response = request . run
5455
5556 if @config . debugging
@@ -188,19 +189,17 @@ def download_file(request)
188189 chunk . force_encoding ( encoding )
189190 tempfile . write ( chunk )
190191 end
191- # run the request to ensure the tempfile is created successfully before returning it
192- request . run
193- if tempfile
192+ request . on_complete do
193+ if !tempfile
194+ fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
195+ end
194196 tempfile . close
195197 @config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
196198 "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
197199 "will be deleted automatically with GC. It's also recommended to delete the temp file " \
198200 "explicitly with `tempfile.delete`"
199- else
200- fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
201+ yield tempfile if block_given?
201202 end
202-
203- tempfile
204203 end
205204
206205 # Check if the given MIME is a JSON MIME.
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ def self.default
4949 # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
5050 def call_api ( http_method , path , opts = { } )
5151 request = build_request ( http_method , path , opts )
52- tempfile = download_file ( request ) if opts [ :return_type ] == 'File'
52+ tempfile = nil
53+ ( download_file ( request ) { tempfile = _1 } ) if opts [ :return_type ] == 'File'
5354 response = request . run
5455
5556 if @config . debugging
@@ -187,19 +188,17 @@ def download_file(request)
187188 chunk . force_encoding ( encoding )
188189 tempfile . write ( chunk )
189190 end
190- # run the request to ensure the tempfile is created successfully before returning it
191- request . run
192- if tempfile
191+ request . on_complete do
192+ if !tempfile
193+ fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
194+ end
193195 tempfile . close
194196 @config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
195197 "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
196198 "will be deleted automatically with GC. It's also recommended to delete the temp file " \
197199 "explicitly with `tempfile.delete`"
198- else
199- fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
200+ yield tempfile if block_given?
200201 end
201-
202- tempfile
203202 end
204203
205204 # Check if the given MIME is a JSON MIME.
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ def self.default
4949 # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
5050 def call_api ( http_method , path , opts = { } )
5151 request = build_request ( http_method , path , opts )
52- tempfile = download_file ( request ) if opts [ :return_type ] == 'File'
52+ tempfile = nil
53+ ( download_file ( request ) { tempfile = _1 } ) if opts [ :return_type ] == 'File'
5354 response = request . run
5455
5556 if @config . debugging
@@ -187,19 +188,17 @@ def download_file(request)
187188 chunk . force_encoding ( encoding )
188189 tempfile . write ( chunk )
189190 end
190- # run the request to ensure the tempfile is created successfully before returning it
191- request . run
192- if tempfile
191+ request . on_complete do
192+ if !tempfile
193+ fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
194+ end
193195 tempfile . close
194196 @config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
195197 "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
196198 "will be deleted automatically with GC. It's also recommended to delete the temp file " \
197199 "explicitly with `tempfile.delete`"
198- else
199- fail ApiError . new ( "Failed to create the tempfile based on the HTTP response from the server: #{ request . inspect } " )
200+ yield tempfile if block_given?
200201 end
201-
202- tempfile
203202 end
204203
205204 # Check if the given MIME is a JSON MIME.
You can’t perform that action at this time.
0 commit comments