File tree 7 files changed +49
-56
lines changed
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
7 files changed +49
-56
lines changed Original file line number Diff line number Diff line change 4
4
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
5
5
def call_api(http_method, path, opts = { } )
6
6
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'
8
9
response = request.run
9
10
10
11
if @config.debugging
145
146
chunk.force_encoding(encoding)
146
147
tempfile.write(chunk)
147
148
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
151
153
tempfile.close
152
154
@config.logger.info "Temp file written to #{ tempfile.path} , please copy the file to a proper folder "\
153
155
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
154
156
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
155
157
"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?
158
159
end
159
-
160
- tempfile
161
160
end
Original file line number Diff line number Diff line change @@ -49,7 +49,8 @@ def self.default
49
49
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
50
50
def call_api ( http_method , path , opts = { } )
51
51
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'
53
54
response = request . run
54
55
55
56
if @config . debugging
@@ -188,19 +189,17 @@ def download_file(request)
188
189
chunk . force_encoding ( encoding )
189
190
tempfile . write ( chunk )
190
191
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
194
196
tempfile . close
195
197
@config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
196
198
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
197
199
"will be deleted automatically with GC. It's also recommended to delete the temp file " \
198
200
"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?
201
202
end
202
-
203
- tempfile
204
203
end
205
204
206
205
# 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
49
49
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
50
50
def call_api ( http_method , path , opts = { } )
51
51
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'
53
54
response = request . run
54
55
55
56
if @config . debugging
@@ -188,19 +189,17 @@ def download_file(request)
188
189
chunk . force_encoding ( encoding )
189
190
tempfile . write ( chunk )
190
191
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
194
196
tempfile . close
195
197
@config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
196
198
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
197
199
"will be deleted automatically with GC. It's also recommended to delete the temp file " \
198
200
"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?
201
202
end
202
-
203
- tempfile
204
203
end
205
204
206
205
# 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
49
49
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
50
50
def call_api ( http_method , path , opts = { } )
51
51
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'
53
54
response = request . run
54
55
55
56
if @config . debugging
@@ -188,19 +189,17 @@ def download_file(request)
188
189
chunk . force_encoding ( encoding )
189
190
tempfile . write ( chunk )
190
191
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
194
196
tempfile . close
195
197
@config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
196
198
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
197
199
"will be deleted automatically with GC. It's also recommended to delete the temp file " \
198
200
"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?
201
202
end
202
-
203
- tempfile
204
203
end
205
204
206
205
# 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
49
49
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
50
50
def call_api ( http_method , path , opts = { } )
51
51
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'
53
54
response = request . run
54
55
55
56
if @config . debugging
@@ -188,19 +189,17 @@ def download_file(request)
188
189
chunk . force_encoding ( encoding )
189
190
tempfile . write ( chunk )
190
191
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
194
196
tempfile . close
195
197
@config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
196
198
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
197
199
"will be deleted automatically with GC. It's also recommended to delete the temp file " \
198
200
"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?
201
202
end
202
-
203
- tempfile
204
203
end
205
204
206
205
# 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
49
49
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
50
50
def call_api ( http_method , path , opts = { } )
51
51
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'
53
54
response = request . run
54
55
55
56
if @config . debugging
@@ -187,19 +188,17 @@ def download_file(request)
187
188
chunk . force_encoding ( encoding )
188
189
tempfile . write ( chunk )
189
190
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
193
195
tempfile . close
194
196
@config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
195
197
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
196
198
"will be deleted automatically with GC. It's also recommended to delete the temp file " \
197
199
"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?
200
201
end
201
-
202
- tempfile
203
202
end
204
203
205
204
# 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
49
49
# the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
50
50
def call_api ( http_method , path , opts = { } )
51
51
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'
53
54
response = request . run
54
55
55
56
if @config . debugging
@@ -187,19 +188,17 @@ def download_file(request)
187
188
chunk . force_encoding ( encoding )
188
189
tempfile . write ( chunk )
189
190
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
193
195
tempfile . close
194
196
@config . logger . info "Temp file written to #{ tempfile . path } , please copy the file to a proper folder " \
195
197
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file " \
196
198
"will be deleted automatically with GC. It's also recommended to delete the temp file " \
197
199
"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?
200
201
end
201
-
202
- tempfile
203
202
end
204
203
205
204
# Check if the given MIME is a JSON MIME.
You can’t perform that action at this time.
0 commit comments