docraptor 1.1.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,21 @@
1
+ =begin
2
+ #DocRaptor
3
+
4
+ #A native client library for the DocRaptor HTML to PDF/XLS service.
5
+
6
+ OpenAPI spec version: 1.4.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.19
10
+
11
+ =end
12
+
1
13
  require 'date'
2
14
  require 'json'
3
15
  require 'logger'
4
16
  require 'tempfile'
5
17
  require 'typhoeus'
6
- require 'uri'
18
+ require 'addressable/uri'
7
19
 
8
20
  module DocRaptor
9
21
  class ApiClient
@@ -15,11 +27,13 @@ module DocRaptor
15
27
  # @return [Hash]
16
28
  attr_accessor :default_headers
17
29
 
30
+ # Initializes the ApiClient
31
+ # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
18
32
  def initialize(config = Configuration.default)
19
33
  @config = config
20
34
  @user_agent = "ruby-swagger-#{VERSION}"
21
35
  @default_headers = {
22
- 'Content-Type' => "application/json",
36
+ 'Content-Type' => 'application/json',
23
37
  'User-Agent' => @user_agent
24
38
  }
25
39
  end
@@ -41,10 +55,18 @@ module DocRaptor
41
55
  end
42
56
 
43
57
  unless response.success?
44
- fail ApiError.new(:code => response.code,
45
- :response_headers => response.headers,
46
- :response_body => response.body),
47
- response.status_message
58
+ if response.timed_out?
59
+ fail ApiError.new('Connection timed out')
60
+ elsif response.code == 0
61
+ # Errors from libcurl will be made visible here
62
+ fail ApiError.new(:code => 0,
63
+ :message => response.return_message)
64
+ else
65
+ fail ApiError.new(:code => response.code,
66
+ :response_headers => response.headers.to_h,
67
+ :response_body => response.body),
68
+ response.status_message
69
+ end
48
70
  end
49
71
 
50
72
  if opts[:return_type]
@@ -55,6 +77,15 @@ module DocRaptor
55
77
  return data, response.code, response.headers
56
78
  end
57
79
 
80
+ # Builds the HTTP request
81
+ #
82
+ # @param [String] http_method HTTP method/verb (e.g. POST)
83
+ # @param [String] path URL path (e.g. /account/new)
84
+ # @option opts [Hash] :header_params Header parameters
85
+ # @option opts [Hash] :query_params Query parameters
86
+ # @option opts [Hash] :form_params Query parameters
87
+ # @option opts [Object] :body HTTP body (JSON/XML)
88
+ # @return [Typhoeus::Request] A Typhoeus Request
58
89
  def build_request(http_method, path, opts = {})
59
90
  url = build_request_url(path)
60
91
  http_method = http_method.to_sym.downcase
@@ -63,21 +94,27 @@ module DocRaptor
63
94
  query_params = opts[:query_params] || {}
64
95
  form_params = opts[:form_params] || {}
65
96
 
66
-
67
97
  update_params_for_auth! header_params, query_params, opts[:auth_names]
68
98
 
99
+ # set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
100
+ _verify_ssl_host = @config.verify_ssl_host ? 2 : 0
69
101
 
70
102
  req_opts = {
71
103
  :method => http_method,
72
104
  :headers => header_params,
73
105
  :params => query_params,
106
+ :params_encoding => @config.params_encoding,
74
107
  :timeout => @config.timeout,
75
108
  :ssl_verifypeer => @config.verify_ssl,
109
+ :ssl_verifyhost => _verify_ssl_host,
76
110
  :sslcert => @config.cert_file,
77
111
  :sslkey => @config.key_file,
78
112
  :verbose => @config.debugging
79
113
  }
80
114
 
115
+ req_opts.merge!(multipart: true) if header_params['Content-Type'].start_with? "multipart/"
116
+
117
+ # set custom cert, if provided
81
118
  req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
82
119
 
83
120
  if [:post, :patch, :put, :delete].include?(http_method)
@@ -88,7 +125,9 @@ module DocRaptor
88
125
  end
89
126
  end
90
127
 
91
- Typhoeus::Request.new(url, req_opts)
128
+ request = Typhoeus::Request.new(url, req_opts)
129
+ download_file(request) if opts[:return_type] == 'File'
130
+ request
92
131
  end
93
132
 
94
133
  # Check if the given MIME is a JSON MIME.
@@ -96,23 +135,29 @@ module DocRaptor
96
135
  # application/json
97
136
  # application/json; charset=UTF8
98
137
  # APPLICATION/JSON
138
+ # */*
139
+ # @param [String] mime MIME
140
+ # @return [Boolean] True if the MIME is application/json
99
141
  def json_mime?(mime)
100
- !!(mime =~ /\Aapplication\/json(;.*)?\z/i)
142
+ (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
101
143
  end
102
144
 
103
145
  # Deserialize the response to the given return type.
104
146
  #
147
+ # @param [Response] response HTTP response
105
148
  # @param [String] return_type some examples: "User", "Array[User]", "Hash[String,Integer]"
106
149
  def deserialize(response, return_type)
107
150
  body = response.body
151
+
152
+ # handle file downloading - return the File instance processed in request callbacks
153
+ # note that response body is empty when the file is written in chunks in request on_body callback
154
+ return @tempfile if return_type == 'File'
155
+
108
156
  return nil if body.nil? || body.empty?
109
157
 
110
158
  # return response body directly for String return type
111
159
  return body if return_type == 'String'
112
160
 
113
- # handle file downloading - save response body into a tmp file and return the File instance
114
- return download_file(response) if return_type == 'File'
115
-
116
161
  # ensuring a default content type
117
162
  content_type = response.headers['Content-Type'] || 'application/json'
118
163
 
@@ -132,6 +177,9 @@ module DocRaptor
132
177
  end
133
178
 
134
179
  # Convert data to the given return type.
180
+ # @param [Object] data Data to be converted
181
+ # @param [String] return_type Return type
182
+ # @return [Mixed] Data in a particular type
135
183
  def convert_to_type(data, return_type)
136
184
  return nil if data.nil?
137
185
  case return_type
@@ -155,12 +203,12 @@ module DocRaptor
155
203
  when /\AArray<(.+)>\z/
156
204
  # e.g. Array<Pet>
157
205
  sub_type = $1
158
- data.map {|item| convert_to_type(item, sub_type) }
206
+ data.map { |item| convert_to_type(item, sub_type) }
159
207
  when /\AHash\<String, (.+)\>\z/
160
208
  # e.g. Hash<String, Integer>
161
209
  sub_type = $1
162
210
  {}.tap do |hash|
163
- 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) }
164
212
  end
165
213
  else
166
214
  # models, e.g. Pet
@@ -172,30 +220,38 @@ module DocRaptor
172
220
 
173
221
  # Save response body into a file in (the defined) temporary folder, using the filename
174
222
  # from the "Content-Disposition" header if provided, otherwise a random filename.
223
+ # The response body is written to the file in chunks in order to handle files which
224
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
225
+ # process can use.
175
226
  #
176
227
  # @see Configuration#temp_folder_path
177
- # @return [Tempfile] the file downloaded
178
- def download_file(response)
179
- content_disposition = response.headers['Content-Disposition']
180
- if content_disposition
181
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
182
- prefix = sanitize_filename(filename)
183
- else
184
- prefix = 'download-'
185
- end
186
- prefix = prefix + '-' unless prefix.end_with?('-')
187
-
228
+ def download_file(request)
188
229
  tempfile = nil
189
- encoding = response.body.encoding
190
- Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding) do |file|
191
- file.write(response.body)
192
- tempfile = file
230
+ encoding = nil
231
+ request.on_headers do |response|
232
+ content_disposition = response.headers['Content-Disposition']
233
+ if content_disposition && content_disposition =~ /filename=/i
234
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
235
+ prefix = sanitize_filename(filename)
236
+ else
237
+ prefix = 'download-'
238
+ end
239
+ prefix = prefix + '-' unless prefix.end_with?('-')
240
+ encoding = response.body.encoding
241
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
242
+ @tempfile = tempfile
243
+ end
244
+ request.on_body do |chunk|
245
+ chunk.force_encoding(encoding)
246
+ tempfile.write(chunk)
247
+ end
248
+ request.on_complete do |response|
249
+ tempfile.close
250
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
251
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
252
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
253
+ "explicitly with `tempfile.delete`"
193
254
  end
194
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
195
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
196
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
197
- "explicitly with `tempfile.delete`"
198
- tempfile
199
255
  end
200
256
 
201
257
  # Sanitize filename by removing path.
@@ -204,15 +260,21 @@ module DocRaptor
204
260
  # @param [String] filename the filename to be sanitized
205
261
  # @return [String] the sanitized filename
206
262
  def sanitize_filename(filename)
207
- filename.gsub /.*[\/\\]/, ''
263
+ filename.gsub(/.*[\/\\]/, '')
208
264
  end
209
265
 
210
266
  def build_request_url(path)
211
267
  # Add leading and trailing slashes to path
212
268
  path = "/#{path}".gsub(/\/+/, '/')
213
- URI.encode(@config.base_url + path)
269
+ Addressable::URI.encode(@config.base_url + path)
214
270
  end
215
271
 
272
+ # Builds the HTTP request body
273
+ #
274
+ # @param [Hash] header_params Header parameters
275
+ # @param [Hash] form_params Query parameters
276
+ # @param [Object] body HTTP body (JSON/XML)
277
+ # @return [String] HTTP body data in the form of string
216
278
  def build_request_body(header_params, form_params, body)
217
279
  # http form
218
280
  if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
@@ -220,7 +282,7 @@ module DocRaptor
220
282
  data = {}
221
283
  form_params.each do |key, value|
222
284
  case value
223
- when File, Array, nil
285
+ when ::File, ::Array, nil
224
286
  # let typhoeus handle File, Array and nil parameters
225
287
  data[key] = value
226
288
  else
@@ -236,6 +298,10 @@ module DocRaptor
236
298
  end
237
299
 
238
300
  # Update hearder and query params based on authentication settings.
301
+ #
302
+ # @param [Hash] header_params Header parameters
303
+ # @param [Hash] query_params Query parameters
304
+ # @param [String] auth_names Authentication scheme name
239
305
  def update_params_for_auth!(header_params, query_params, auth_names)
240
306
  Array(auth_names).each do |auth_name|
241
307
  auth_setting = @config.auth_settings[auth_name]
@@ -248,6 +314,9 @@ module DocRaptor
248
314
  end
249
315
  end
250
316
 
317
+ # Sets user agent in HTTP header
318
+ #
319
+ # @param [String] user_agent User agent (e.g. swagger-codegen/ruby/1.0.0)
251
320
  def user_agent=(user_agent)
252
321
  @user_agent = user_agent
253
322
  @default_headers['User-Agent'] = @user_agent
@@ -260,7 +329,7 @@ module DocRaptor
260
329
  return nil if accepts.nil? || accepts.empty?
261
330
  # use JSON when present, otherwise use all of the provided
262
331
  json_accept = accepts.find { |s| json_mime?(s) }
263
- return json_accept || accepts.join(',')
332
+ json_accept || accepts.join(',')
264
333
  end
265
334
 
266
335
  # Return Content-Type header based on an array of content types provided.
@@ -271,7 +340,7 @@ module DocRaptor
271
340
  return 'application/json' if content_types.nil? || content_types.empty?
272
341
  # use JSON when present, otherwise use the first one
273
342
  json_content_type = content_types.find { |s| json_mime?(s) }
274
- return json_content_type || content_types.first
343
+ json_content_type || content_types.first
275
344
  end
276
345
 
277
346
  # Convert object (array, hash, object, etc) to JSON string.
@@ -279,13 +348,13 @@ module DocRaptor
279
348
  # @return [String] JSON string representation of the object
280
349
  def object_to_http_body(model)
281
350
  return model if model.nil? || model.is_a?(String)
282
- _body = nil
351
+ local_body = nil
283
352
  if model.is_a?(Array)
284
- _body = model.map{|m| object_to_hash(m) }
353
+ local_body = model.map { |m| object_to_hash(m) }
285
354
  else
286
- _body = object_to_hash(model)
355
+ local_body = object_to_hash(model)
287
356
  end
288
- _body.to_json
357
+ local_body.to_json
289
358
  end
290
359
 
291
360
  # Convert object(non-array) to hash.
@@ -1,3 +1,15 @@
1
+ =begin
2
+ #DocRaptor
3
+
4
+ #A native client library for the DocRaptor HTML to PDF/XLS service.
5
+
6
+ OpenAPI spec version: 1.4.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.19
10
+
11
+ =end
12
+
1
13
  module DocRaptor
2
14
  class ApiError < StandardError
3
15
  attr_reader :code, :response_headers, :response_body
@@ -9,12 +21,14 @@ module DocRaptor
9
21
  # ApiError.new(:code => 404, :message => "Not Found")
10
22
  def initialize(arg = nil)
11
23
  if arg.is_a? Hash
24
+ if arg.key?(:message) || arg.key?('message')
25
+ super(arg[:message] || arg['message'])
26
+ else
27
+ super arg
28
+ end
29
+
12
30
  arg.each do |k, v|
13
- if k.to_s == 'message'
14
- super v
15
- else
16
- instance_variable_set "@#{k}", v
17
- end
31
+ instance_variable_set "@#{k}", v
18
32
  end
19
33
  else
20
34
  super arg
@@ -1,4 +1,16 @@
1
- require 'uri'
1
+ =begin
2
+ #DocRaptor
3
+
4
+ #A native client library for the DocRaptor HTML to PDF/XLS service.
5
+
6
+ OpenAPI spec version: 1.4.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.19
10
+
11
+ =end
12
+
13
+ require 'addressable/uri'
2
14
 
3
15
  module DocRaptor
4
16
  class Configuration
@@ -64,7 +76,12 @@ module DocRaptor
64
76
  # Default to 0 (never times out).
65
77
  attr_accessor :timeout
66
78
 
67
- ### TLS/SSL
79
+ # Set this to false to skip client side validation in the operation.
80
+ # Default to true.
81
+ # @return [true, false]
82
+ attr_accessor :client_side_validation
83
+
84
+ ### TLS/SSL setting
68
85
  # Set this to false to skip verifying SSL certificate when calling API from https server.
69
86
  # Default to true.
70
87
  #
@@ -73,6 +90,16 @@ module DocRaptor
73
90
  # @return [true, false]
74
91
  attr_accessor :verify_ssl
75
92
 
93
+ ### TLS/SSL setting
94
+ # Set this to false to skip verifying SSL host name
95
+ # Default to true.
96
+ #
97
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
98
+ #
99
+ # @return [true, false]
100
+ attr_accessor :verify_ssl_host
101
+
102
+ ### TLS/SSL setting
76
103
  # Set this to customize the certificate file to verify the peer.
77
104
  #
78
105
  # @return [String] the path to the certificate file
@@ -81,12 +108,21 @@ module DocRaptor
81
108
  # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
82
109
  attr_accessor :ssl_ca_cert
83
110
 
111
+ ### TLS/SSL setting
84
112
  # Client certificate file (for client certificate)
85
113
  attr_accessor :cert_file
86
114
 
115
+ ### TLS/SSL setting
87
116
  # Client private key file (for client certificate)
88
117
  attr_accessor :key_file
89
118
 
119
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
120
+ # Default to nil.
121
+ #
122
+ # @see The params_encoding option of Ethon. Related source code:
123
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
124
+ attr_accessor :params_encoding
125
+
90
126
  attr_accessor :inject_format
91
127
 
92
128
  attr_accessor :force_ending_format
@@ -98,7 +134,10 @@ module DocRaptor
98
134
  @api_key = {}
99
135
  @api_key_prefix = {}
100
136
  @timeout = 0
137
+ @client_side_validation = true
101
138
  @verify_ssl = true
139
+ @verify_ssl_host = true
140
+ @params_encoding = nil
102
141
  @cert_file = nil
103
142
  @key_file = nil
104
143
  @debugging = false
@@ -131,12 +170,12 @@ module DocRaptor
131
170
  def base_path=(base_path)
132
171
  # Add leading and trailing slashes to base_path
133
172
  @base_path = "/#{base_path}".gsub(/\/+/, '/')
134
- @base_path = "" if @base_path == "/"
173
+ @base_path = '' if @base_path == '/'
135
174
  end
136
175
 
137
176
  def base_url
138
177
  url = "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
139
- URI.encode(url)
178
+ Addressable::URI.encode(url)
140
179
  end
141
180
 
142
181
  # Gets API key (with prefix if set).
@@ -1,16 +1,26 @@
1
+ =begin
2
+ #DocRaptor
3
+
4
+ #A native client library for the DocRaptor HTML to PDF/XLS service.
5
+
6
+ OpenAPI spec version: 1.4.0
7
+
8
+ Generated by: https://github.com/swagger-api/swagger-codegen.git
9
+ Swagger Codegen version: 2.4.19
10
+
11
+ =end
12
+
1
13
  require 'date'
2
14
 
3
15
  module DocRaptor
4
16
  class AsyncDoc
5
- # The identifier used to get the status of the document using the status api.
17
+ # The identifier used to get the status of the document using the status API.
6
18
  attr_accessor :status_id
7
19
 
8
20
  # Attribute mapping from ruby-style variable name to JSON key.
9
21
  def self.attribute_map
10
22
  {
11
-
12
23
  :'status_id' => :'status_id'
13
-
14
24
  }
15
25
  end
16
26
 
@@ -18,24 +28,37 @@ module DocRaptor
18
28
  def self.swagger_types
19
29
  {
20
30
  :'status_id' => :'String'
21
-
22
31
  }
23
32
  end
24
33
 
34
+ # Initializes the object
35
+ # @param [Hash] attributes Model attributes in the form of hash
25
36
  def initialize(attributes = {})
26
37
  return unless attributes.is_a?(Hash)
27
38
 
28
39
  # convert string to symbol for hash key
29
- attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
30
-
40
+ attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
31
41
 
32
- if attributes[:'status_id']
42
+ if attributes.has_key?(:'status_id')
33
43
  self.status_id = attributes[:'status_id']
34
44
  end
45
+ end
35
46
 
47
+ # Show invalid properties with the reasons. Usually used together with valid?
48
+ # @return Array for valid properties with the reasons
49
+ def list_invalid_properties
50
+ invalid_properties = Array.new
51
+ invalid_properties
36
52
  end
37
53
 
38
- # Check equality by comparing each attribute.
54
+ # Check to see if the all the properties in the model are valid
55
+ # @return true if the model is valid
56
+ def valid?
57
+ true
58
+ end
59
+
60
+ # Checks equality by comparing each attribute.
61
+ # @param [Object] Object to be compared
39
62
  def ==(o)
40
63
  return true if self.equal?(o)
41
64
  self.class == o.class &&
@@ -43,35 +66,41 @@ module DocRaptor
43
66
  end
44
67
 
45
68
  # @see the `==` method
69
+ # @param [Object] Object to be compared
46
70
  def eql?(o)
47
71
  self == o
48
72
  end
49
73
 
50
- # Calculate hash code according to all attributes.
74
+ # Calculates hash code according to all attributes.
75
+ # @return [Fixnum] Hash code
51
76
  def hash
52
77
  [status_id].hash
53
78
  end
54
79
 
55
- # build the object from hash
80
+ # Builds the object from hash
81
+ # @param [Hash] attributes Model attributes in the form of hash
82
+ # @return [Object] Returns the model itself
56
83
  def build_from_hash(attributes)
57
84
  return nil unless attributes.is_a?(Hash)
58
85
  self.class.swagger_types.each_pair do |key, type|
59
- if type =~ /^Array<(.*)>/i
86
+ if type =~ /\AArray<(.*)>/i
87
+ # check to ensure the input is an array given that the attribute
88
+ # is documented as an array but the input is not
60
89
  if attributes[self.class.attribute_map[key]].is_a?(Array)
61
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
62
- else
63
- #TODO show warning in debug mode
90
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
64
91
  end
65
92
  elsif !attributes[self.class.attribute_map[key]].nil?
66
93
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
67
- else
68
- # data not found in attributes(hash), not an issue as the data can be optional
69
- end
94
+ end # or else data not found in attributes(hash), not an issue as the data can be optional
70
95
  end
71
96
 
72
97
  self
73
98
  end
74
99
 
100
+ # Deserializes the data based on type
101
+ # @param string type Data type
102
+ # @param string value Value to be deserialized
103
+ # @return [Object] Deserialized data
75
104
  def _deserialize(type, value)
76
105
  case type.to_sym
77
106
  when :DateTime
@@ -85,7 +114,7 @@ module DocRaptor
85
114
  when :Float
86
115
  value.to_f
87
116
  when :BOOLEAN
88
- if value.to_s =~ /^(true|t|yes|y|1)$/i
117
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
89
118
  true
90
119
  else
91
120
  false
@@ -96,7 +125,7 @@ module DocRaptor
96
125
  when /\AArray<(?<inner_type>.+)>\z/
97
126
  inner_type = Regexp.last_match[:inner_type]
98
127
  value.map { |v| _deserialize(inner_type, v) }
99
- when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
128
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
100
129
  k_type = Regexp.last_match[:k_type]
101
130
  v_type = Regexp.last_match[:v_type]
102
131
  {}.tap do |hash|
@@ -105,21 +134,25 @@ module DocRaptor
105
134
  end
106
135
  end
107
136
  else # model
108
- _model = DocRaptor.const_get(type).new
109
- _model.build_from_hash(value)
137
+ temp_model = DocRaptor.const_get(type).new
138
+ temp_model.build_from_hash(value)
110
139
  end
111
140
  end
112
141
 
142
+ # Returns the string representation of the object
143
+ # @return [String] String presentation of the object
113
144
  def to_s
114
145
  to_hash.to_s
115
146
  end
116
147
 
117
- # to_body is an alias to to_body (backward compatibility))
148
+ # to_body is an alias to to_hash (backward compatibility)
149
+ # @return [Hash] Returns the object in the form of hash
118
150
  def to_body
119
151
  to_hash
120
152
  end
121
153
 
122
- # return the object in the form of hash
154
+ # Returns the object in the form of hash
155
+ # @return [Hash] Returns the object in the form of hash
123
156
  def to_hash
124
157
  hash = {}
125
158
  self.class.attribute_map.each_pair do |attr, param|
@@ -130,11 +163,13 @@ module DocRaptor
130
163
  hash
131
164
  end
132
165
 
133
- # Method to output non-array value in the form of hash
166
+ # Outputs non-array value in the form of hash
134
167
  # For object, use to_hash. Otherwise, just return the value
168
+ # @param [Object] value Any valid value
169
+ # @return [Hash] Returns the value in the form of hash
135
170
  def _to_hash(value)
136
171
  if value.is_a?(Array)
137
- value.compact.map{ |v| _to_hash(v) }
172
+ value.compact.map { |v| _to_hash(v) }
138
173
  elsif value.is_a?(Hash)
139
174
  {}.tap do |hash|
140
175
  value.each { |k, v| hash[k] = _to_hash(v) }