66OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
77Contact: [email protected] */ ' \" =_end -- \\r\\n \\n \\r 88Generated 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
1010
1111=end
1212
1515require 'logger'
1616require 'tempfile'
1717require 'typhoeus'
18- require 'uri'
18+ require 'addressable/ uri'
1919
2020module Petstore
2121 class ApiClient
@@ -33,7 +33,7 @@ def initialize(config = Configuration.default)
3333 @config = config
3434 @user_agent = "Swagger-Codegen/#{ VERSION } /ruby"
3535 @default_headers = {
36- 'Content-Type' => " application/json" ,
36+ 'Content-Type' => ' application/json' ,
3737 'User-Agent' => @user_agent
3838 }
3939 end
@@ -63,7 +63,7 @@ def call_api(http_method, path, opts = {})
6363 :message => response . return_message )
6464 else
6565 fail ApiError . new ( :code => response . code ,
66- :response_headers => response . headers ,
66+ :response_headers => response . headers . to_h ,
6767 :response_body => response . body ) ,
6868 response . status_message
6969 end
@@ -112,6 +112,8 @@ def build_request(http_method, path, opts = {})
112112 :verbose => @config . debugging
113113 }
114114
115+ req_opts . merge! ( multipart : true ) if header_params [ 'Content-Type' ] . start_with? "multipart/"
116+
115117 # set custom cert, if provided
116118 req_opts [ :cainfo ] = @config . ssl_ca_cert if @config . ssl_ca_cert
117119
@@ -137,7 +139,7 @@ def build_request(http_method, path, opts = {})
137139 # @param [String] mime MIME
138140 # @return [Boolean] True if the MIME is application/json
139141 def json_mime? ( mime )
140- ( mime == " */*" ) || !( mime =~ /Application\/ .*json(?!p)(;.*)?/i ) . nil?
142+ ( mime == ' */*' ) || !( mime =~ /Application\/ .*json(?!p)(;.*)?/i ) . nil?
141143 end
142144
143145 # Deserialize the response to the given return type.
@@ -201,12 +203,12 @@ def convert_to_type(data, return_type)
201203 when /\A Array<(.+)>\z /
202204 # e.g. Array<Pet>
203205 sub_type = $1
204- data . map { |item | convert_to_type ( item , sub_type ) }
206+ data . map { |item | convert_to_type ( item , sub_type ) }
205207 when /\A Hash\< String, (.+)\> \z /
206208 # e.g. Hash<String, Integer>
207209 sub_type = $1
208210 { } . 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 ) }
210212 end
211213 else
212214 # models, e.g. Pet
@@ -228,7 +230,7 @@ def download_file(request)
228230 encoding = nil
229231 request . on_headers do |response |
230232 content_disposition = response . headers [ 'Content-Disposition' ]
231- if content_disposition and content_disposition =~ /filename=/i
233+ if content_disposition && content_disposition =~ /filename=/i
232234 filename = content_disposition [ /filename=['"]?([^'"\s ]+)['"]?/ , 1 ]
233235 prefix = sanitize_filename ( filename )
234236 else
@@ -264,7 +266,7 @@ def sanitize_filename(filename)
264266 def build_request_url ( path )
265267 # Add leading and trailing slashes to path
266268 path = "/#{ path } " . gsub ( /\/ +/ , '/' )
267- URI . encode ( @config . base_url + path )
269+ Addressable :: URI . encode ( @config . base_url + path )
268270 end
269271
270272 # Builds the HTTP request body
@@ -327,7 +329,7 @@ def select_header_accept(accepts)
327329 return nil if accepts . nil? || accepts . empty?
328330 # use JSON when present, otherwise use all of the provided
329331 json_accept = accepts . find { |s | json_mime? ( s ) }
330- return json_accept || accepts . join ( ',' )
332+ json_accept || accepts . join ( ',' )
331333 end
332334
333335 # Return Content-Type header based on an array of content types provided.
@@ -338,7 +340,7 @@ def select_header_content_type(content_types)
338340 return 'application/json' if content_types . nil? || content_types . empty?
339341 # use JSON when present, otherwise use the first one
340342 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
342344 end
343345
344346 # Convert object (array, hash, object, etc) to JSON string.
@@ -348,7 +350,7 @@ def object_to_http_body(model)
348350 return model if model . nil? || model . is_a? ( String )
349351 local_body = nil
350352 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 ) }
352354 else
353355 local_body = object_to_hash ( model )
354356 end
0 commit comments