6
6
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
7
7
Contact: [email protected] */ ' \" =_end -- \\r\\n \\n \\r
8
8
Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.0 -SNAPSHOT
9
+ Swagger Codegen version: 2.4.42 -SNAPSHOT
10
10
11
11
=end
12
12
15
15
require 'logger'
16
16
require 'tempfile'
17
17
require 'typhoeus'
18
- require 'uri'
18
+ require 'addressable/ uri'
19
19
20
20
module Petstore
21
21
class ApiClient
@@ -33,7 +33,7 @@ def initialize(config = Configuration.default)
33
33
@config = config
34
34
@user_agent = "Swagger-Codegen/#{ VERSION } /ruby"
35
35
@default_headers = {
36
- 'Content-Type' => " application/json" ,
36
+ 'Content-Type' => ' application/json' ,
37
37
'User-Agent' => @user_agent
38
38
}
39
39
end
@@ -63,7 +63,7 @@ def call_api(http_method, path, opts = {})
63
63
:message => response . return_message )
64
64
else
65
65
fail ApiError . new ( :code => response . code ,
66
- :response_headers => response . headers ,
66
+ :response_headers => response . headers . to_h ,
67
67
:response_body => response . body ) ,
68
68
response . status_message
69
69
end
@@ -112,6 +112,8 @@ def build_request(http_method, path, opts = {})
112
112
:verbose => @config . debugging
113
113
}
114
114
115
+ req_opts . merge! ( multipart : true ) if header_params [ 'Content-Type' ] . start_with? "multipart/"
116
+
115
117
# set custom cert, if provided
116
118
req_opts [ :cainfo ] = @config . ssl_ca_cert if @config . ssl_ca_cert
117
119
@@ -137,7 +139,7 @@ def build_request(http_method, path, opts = {})
137
139
# @param [String] mime MIME
138
140
# @return [Boolean] True if the MIME is application/json
139
141
def json_mime? ( mime )
140
- ( mime == " */*" ) || !( mime =~ /Application\/ .*json(?!p)(;.*)?/i ) . nil?
142
+ ( mime == ' */*' ) || !( mime =~ /Application\/ .*json(?!p)(;.*)?/i ) . nil?
141
143
end
142
144
143
145
# Deserialize the response to the given return type.
@@ -201,12 +203,12 @@ def convert_to_type(data, return_type)
201
203
when /\A Array<(.+)>\z /
202
204
# e.g. Array<Pet>
203
205
sub_type = $1
204
- data . map { |item | convert_to_type ( item , sub_type ) }
206
+ data . map { |item | convert_to_type ( item , sub_type ) }
205
207
when /\A Hash\< String, (.+)\> \z /
206
208
# e.g. Hash<String, Integer>
207
209
sub_type = $1
208
210
{ } . tap do |hash |
209
- data . each { |k , v | hash [ k ] = convert_to_type ( v , sub_type ) }
211
+ data . each { |k , v | hash [ k ] = convert_to_type ( v , sub_type ) }
210
212
end
211
213
else
212
214
# models, e.g. Pet
@@ -228,7 +230,7 @@ def download_file(request)
228
230
encoding = nil
229
231
request . on_headers do |response |
230
232
content_disposition = response . headers [ 'Content-Disposition' ]
231
- if content_disposition and content_disposition =~ /filename=/i
233
+ if content_disposition && content_disposition =~ /filename=/i
232
234
filename = content_disposition [ /filename=['"]?([^'"\s ]+)['"]?/ , 1 ]
233
235
prefix = sanitize_filename ( filename )
234
236
else
@@ -264,7 +266,7 @@ def sanitize_filename(filename)
264
266
def build_request_url ( path )
265
267
# Add leading and trailing slashes to path
266
268
path = "/#{ path } " . gsub ( /\/ +/ , '/' )
267
- URI . encode ( @config . base_url + path )
269
+ Addressable :: URI . encode ( @config . base_url + path )
268
270
end
269
271
270
272
# Builds the HTTP request body
@@ -327,7 +329,7 @@ def select_header_accept(accepts)
327
329
return nil if accepts . nil? || accepts . empty?
328
330
# use JSON when present, otherwise use all of the provided
329
331
json_accept = accepts . find { |s | json_mime? ( s ) }
330
- return json_accept || accepts . join ( ',' )
332
+ json_accept || accepts . join ( ',' )
331
333
end
332
334
333
335
# Return Content-Type header based on an array of content types provided.
@@ -338,7 +340,7 @@ def select_header_content_type(content_types)
338
340
return 'application/json' if content_types . nil? || content_types . empty?
339
341
# use JSON when present, otherwise use the first one
340
342
json_content_type = content_types . find { |s | json_mime? ( s ) }
341
- return json_content_type || content_types . first
343
+ json_content_type || content_types . first
342
344
end
343
345
344
346
# Convert object (array, hash, object, etc) to JSON string.
@@ -348,7 +350,7 @@ def object_to_http_body(model)
348
350
return model if model . nil? || model . is_a? ( String )
349
351
local_body = nil
350
352
if model . is_a? ( Array )
351
- local_body = model . map { |m | object_to_hash ( m ) }
353
+ local_body = model . map { |m | object_to_hash ( m ) }
352
354
else
353
355
local_body = object_to_hash ( model )
354
356
end
0 commit comments