patch_ruby 1.9.0 → 1.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile +1 -2
  4. data/Gemfile.lock +20 -25
  5. data/lib/patch_ruby/api/estimates_api.rb +33 -25
  6. data/lib/patch_ruby/api/orders_api.rb +21 -16
  7. data/lib/patch_ruby/api/preferences_api.rb +17 -13
  8. data/lib/patch_ruby/api/projects_api.rb +9 -7
  9. data/lib/patch_ruby/api_client.rb +51 -49
  10. data/lib/patch_ruby/api_error.rb +1 -1
  11. data/lib/patch_ruby/configuration.rb +38 -9
  12. data/lib/patch_ruby/models/allocation.rb +21 -11
  13. data/lib/patch_ruby/models/create_bitcoin_estimate_request.rb +25 -19
  14. data/lib/patch_ruby/models/create_ethereum_estimate_request.rb +26 -21
  15. data/lib/patch_ruby/models/create_mass_estimate_request.rb +22 -13
  16. data/lib/patch_ruby/models/create_order_request.rb +21 -11
  17. data/lib/patch_ruby/models/create_preference_request.rb +21 -11
  18. data/lib/patch_ruby/models/error_response.rb +22 -13
  19. data/lib/patch_ruby/models/estimate.rb +22 -13
  20. data/lib/patch_ruby/models/estimate_list_response.rb +22 -13
  21. data/lib/patch_ruby/models/estimate_response.rb +22 -13
  22. data/lib/patch_ruby/models/meta_index_object.rb +23 -15
  23. data/lib/patch_ruby/models/order.rb +23 -15
  24. data/lib/patch_ruby/models/order_list_response.rb +22 -13
  25. data/lib/patch_ruby/models/order_response.rb +22 -13
  26. data/lib/patch_ruby/models/photo.rb +21 -11
  27. data/lib/patch_ruby/models/preference.rb +21 -11
  28. data/lib/patch_ruby/models/preference_list_response.rb +22 -13
  29. data/lib/patch_ruby/models/preference_response.rb +22 -13
  30. data/lib/patch_ruby/models/project.rb +24 -17
  31. data/lib/patch_ruby/models/project_list_response.rb +22 -13
  32. data/lib/patch_ruby/models/project_response.rb +22 -13
  33. data/lib/patch_ruby/models/sdg.rb +21 -11
  34. data/lib/patch_ruby/models/standard.rb +21 -11
  35. data/lib/patch_ruby/version.rb +2 -2
  36. data/lib/patch_ruby.rb +1 -1
  37. data/patch_ruby.gemspec +7 -3
  38. data/spec/api_client_spec.rb +34 -13
  39. data/spec/configuration_spec.rb +1 -1
  40. data/spec/integration/preferences_spec.rb +1 -1
  41. data/spec/models/create_mass_estimate_request_spec.rb +1 -1
  42. data/spec/models/error_response_spec.rb +1 -1
  43. data/spec/models/estimate_list_response_spec.rb +1 -1
  44. data/spec/models/estimate_response_spec.rb +1 -1
  45. data/spec/models/estimate_spec.rb +1 -1
  46. data/spec/models/meta_index_object_spec.rb +1 -1
  47. data/spec/models/order_list_response_spec.rb +1 -1
  48. data/spec/models/order_response_spec.rb +1 -1
  49. data/spec/models/order_spec.rb +1 -1
  50. data/spec/models/preference_list_response_spec.rb +1 -1
  51. data/spec/models/preference_response_spec.rb +1 -1
  52. data/spec/models/project_list_response_spec.rb +1 -1
  53. data/spec/models/project_response_spec.rb +1 -1
  54. data/spec/models/project_spec.rb +1 -1
  55. data/spec/spec_helper.rb +68 -61
  56. metadata +38 -58
  57. data/lib/patch_ruby/.api_client.rb.un~ +0 -0
  58. data/lib/patch_ruby/.configuration.rb.un~ +0 -0
  59. data/lib/patch_ruby/.version.rb.un~ +0 -0
  60. data/lib/patch_ruby/api/.orders_api.rb.un~ +0 -0
  61. data/lib/patch_ruby/models/.create_ethereum_estimate_request.rb.un~ +0 -0
  62. data/spec/.spec_helper.rb.un~ +0 -0
  63. data/spec/integration/.estimates_spec.rb.un~ +0 -0
  64. data/spec/integration/.orders_spec.rb.un~ +0 -0
  65. data/spec/integration/.preferences_spec.rb.un~ +0 -0
  66. data/spec/integration/.projects_spec.rb.un~ +0 -0
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: v1
7
7
  Contact: developers@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.2.1
10
10
 
11
11
  =end
12
12
 
@@ -62,15 +62,16 @@ module Patch
62
62
  form_params = opts[:form_params] || {}
63
63
 
64
64
  # http body (model)
65
- post_body = opts[:body]
65
+ post_body = opts[:debug_body]
66
66
 
67
67
  # return_type
68
- return_type = opts[:return_type] || 'ProjectResponse'
68
+ return_type = opts[:debug_return_type] || 'ProjectResponse'
69
69
 
70
70
  # auth_names
71
- auth_names = opts[:auth_names] || ['bearer_auth']
71
+ auth_names = opts[:debug_auth_names] || ['bearer_auth']
72
72
 
73
73
  new_options = opts.merge(
74
+ :operation => :"ProjectsApi.retrieve_project",
74
75
  :header_params => header_params,
75
76
  :query_params => query_params,
76
77
  :form_params => form_params,
@@ -130,15 +131,16 @@ module Patch
130
131
  form_params = opts[:form_params] || {}
131
132
 
132
133
  # http body (model)
133
- post_body = opts[:body]
134
+ post_body = opts[:debug_body]
134
135
 
135
136
  # return_type
136
- return_type = opts[:return_type] || 'ProjectListResponse'
137
+ return_type = opts[:debug_return_type] || 'ProjectListResponse'
137
138
 
138
139
  # auth_names
139
- auth_names = opts[:auth_names] || ['bearer_auth']
140
+ auth_names = opts[:debug_auth_names] || ['bearer_auth']
140
141
 
141
142
  new_options = opts.merge(
143
+ :operation => :"ProjectsApi.retrieve_projects",
142
144
  :header_params => header_params,
143
145
  :query_params => query_params,
144
146
  :form_params => form_params,
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: v1
7
7
  Contact: developers@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.2.1
10
10
 
11
11
  =end
12
12
 
@@ -14,6 +14,7 @@ require 'date'
14
14
  require 'json'
15
15
  require 'logger'
16
16
  require 'tempfile'
17
+ require 'time'
17
18
  require 'typhoeus'
18
19
 
19
20
  module Patch
@@ -30,7 +31,7 @@ module Patch
30
31
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
31
32
  def initialize(config = Configuration.default)
32
33
  @config = config
33
- @user_agent = "OpenAPI-Generator/#{VERSION}/ruby"
34
+ @user_agent = "patch-ruby/1.10.0"
34
35
  @default_headers = {
35
36
  'Content-Type' => 'application/json',
36
37
  'User-Agent' => @user_agent
@@ -86,7 +87,7 @@ module Patch
86
87
  # @option opts [Object] :body HTTP body (JSON/XML)
87
88
  # @return [Typhoeus::Request] A Typhoeus Request
88
89
  def build_request(http_method, path, opts = {})
89
- url = build_request_url(path)
90
+ url = build_request_url(path, opts)
90
91
  http_method = http_method.to_sym.downcase
91
92
 
92
93
  header_params = @default_headers.merge(opts[:header_params] || {})
@@ -155,6 +156,44 @@ module Patch
155
156
  data
156
157
  end
157
158
 
159
+ # Save response body into a file in (the defined) temporary folder, using the filename
160
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
161
+ # The response body is written to the file in chunks in order to handle files which
162
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
163
+ # process can use.
164
+ #
165
+ # @see Configuration#temp_folder_path
166
+ def download_file(request)
167
+ tempfile = nil
168
+ encoding = nil
169
+ request.on_headers do |response|
170
+ content_disposition = response.headers['Content-Disposition']
171
+ if content_disposition && content_disposition =~ /filename=/i
172
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
173
+ prefix = sanitize_filename(filename)
174
+ else
175
+ prefix = 'download-'
176
+ end
177
+ prefix = prefix + '-' unless prefix.end_with?('-')
178
+ encoding = response.body.encoding
179
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
180
+ @tempfile = tempfile
181
+ end
182
+ request.on_body do |chunk|
183
+ chunk.force_encoding(encoding)
184
+ tempfile.write(chunk)
185
+ end
186
+ request.on_complete do |response|
187
+ if tempfile
188
+ tempfile.close
189
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
190
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
191
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
192
+ "explicitly with `tempfile.delete`"
193
+ end
194
+ end
195
+ end
196
+
158
197
  # Check if the given MIME is a JSON MIME.
159
198
  # JSON MIME examples:
160
199
  # application/json
@@ -191,7 +230,7 @@ module Patch
191
230
  begin
192
231
  data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
193
232
  rescue JSON::ParserError => e
194
- if %w(String Date DateTime).include?(return_type)
233
+ if %w(String Date Time).include?(return_type)
195
234
  data = body
196
235
  else
197
236
  raise e
@@ -216,9 +255,9 @@ module Patch
216
255
  data.to_f
217
256
  when 'Boolean'
218
257
  data == true
219
- when 'DateTime'
258
+ when 'Time'
220
259
  # parse date time (expecting ISO 8601 format)
221
- DateTime.parse data
260
+ Time.parse data
222
261
  when 'Date'
223
262
  # parse date time (expecting ISO 8601 format)
224
263
  Date.parse data
@@ -236,46 +275,9 @@ module Patch
236
275
  data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
237
276
  end
238
277
  else
239
- # models, e.g. Pet
240
- Patch.const_get(return_type).build_from_hash(data)
241
- end
242
- end
243
-
244
- # Save response body into a file in (the defined) temporary folder, using the filename
245
- # from the "Content-Disposition" header if provided, otherwise a random filename.
246
- # The response body is written to the file in chunks in order to handle files which
247
- # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
248
- # process can use.
249
- #
250
- # @see Configuration#temp_folder_path
251
- def download_file(request)
252
- tempfile = nil
253
- encoding = nil
254
- request.on_headers do |response|
255
- content_disposition = response.headers['Content-Disposition']
256
- if content_disposition && content_disposition =~ /filename=/i
257
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
258
- prefix = sanitize_filename(filename)
259
- else
260
- prefix = 'download-'
261
- end
262
- prefix = prefix + '-' unless prefix.end_with?('-')
263
- encoding = response.body.encoding
264
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
265
- @tempfile = tempfile
266
- end
267
- request.on_body do |chunk|
268
- chunk.force_encoding(encoding)
269
- tempfile.write(chunk)
270
- end
271
- request.on_complete do |response|
272
- if tempfile
273
- tempfile.close
274
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
275
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
276
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
277
- "explicitly with `tempfile.delete`"
278
- end
278
+ # models (e.g. Pet) or oneOf
279
+ klass = Patch.const_get(return_type)
280
+ klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
279
281
  end
280
282
  end
281
283
 
@@ -288,10 +290,10 @@ module Patch
288
290
  filename.gsub(/.*[\/\\]/, '')
289
291
  end
290
292
 
291
- def build_request_url(path)
293
+ def build_request_url(path, opts = {})
292
294
  # Add leading and trailing slashes to path
293
295
  path = "/#{path}".gsub(/\/+/, '/')
294
- @config.base_url + path
296
+ @config.base_url(opts[:operation]) + path
295
297
  end
296
298
 
297
299
  # Update hearder and query params based on authentication settings.
@@ -306,7 +308,7 @@ module Patch
306
308
  case auth_setting[:in]
307
309
  when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
308
310
  when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
309
- else fail ArgumentError, 'Authentication token must be in `query` of `header`'
311
+ else fail ArgumentError, 'Authentication token must be in `query` or `header`'
310
312
  end
311
313
  end
312
314
  end
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: v1
7
7
  Contact: developers@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.2.1
10
10
 
11
11
  =end
12
12
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: v1
7
7
  Contact: developers@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.2.1
10
10
 
11
11
  =end
12
12
 
@@ -21,6 +21,18 @@ module Patch
21
21
  # Defines url base path
22
22
  attr_accessor :base_path
23
23
 
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
24
36
  # Defines API keys used with API Key authentications.
25
37
  #
26
38
  # @return [Hash] key: parameter name, value: parameter value (API key)
@@ -129,6 +141,10 @@ module Patch
129
141
  @scheme = 'https'
130
142
  @host = 'api.patch.io'
131
143
  @base_path = ''
144
+ @server_index = 0
145
+ @server_operation_index = {}
146
+ @server_variables = {}
147
+ @server_operation_variables = {}
132
148
  @api_key = {}
133
149
  @api_key_prefix = {}
134
150
  @timeout = 0
@@ -171,17 +187,23 @@ module Patch
171
187
  @base_path = '' if @base_path == '/'
172
188
  end
173
189
 
174
- def base_url
175
- "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
190
+ # Returns base URL for specified operation based on server settings
191
+ def base_url(operation = nil)
192
+ index = server_operation_index.fetch(operation, server_index)
193
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
194
+
195
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
176
196
  end
177
197
 
178
198
  # Gets API key (with prefix if set).
179
199
  # @param [String] param_name the parameter name of API key auth
180
- def api_key_with_prefix(param_name)
200
+ def api_key_with_prefix(param_name, param_alias = nil)
201
+ key = @api_key[param_name]
202
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
181
203
  if @api_key_prefix[param_name]
182
- "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
204
+ "#{@api_key_prefix[param_name]} #{key}"
183
205
  else
184
- @api_key[param_name]
206
+ key
185
207
  end
186
208
  end
187
209
 
@@ -219,12 +241,17 @@ module Patch
219
241
  ]
220
242
  end
221
243
 
244
+ def operation_server_settings
245
+ {
246
+ }
247
+ end
248
+
222
249
  # Returns URL based on server settings
223
250
  #
224
251
  # @param index array index of the server settings
225
252
  # @param variables hash of variable and the corresponding value
226
- def server_url(index, variables = {})
227
- servers = server_settings
253
+ def server_url(index, variables = {}, servers = nil)
254
+ servers = server_settings if servers == nil
228
255
 
229
256
  # check array index out of bound
230
257
  if (index < 0 || index >= servers.size)
@@ -234,10 +261,12 @@ module Patch
234
261
  server = servers[index]
235
262
  url = server[:url]
236
263
 
264
+ return url unless server.key? :variables
265
+
237
266
  # go through variable and assign a value
238
267
  server[:variables].each do |name, variable|
239
268
  if variables.key?(name)
240
- if (server[:variables][name][:enum_values].include? variables[name])
269
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
241
270
  url.gsub! "{" + name.to_s + "}", variables[name]
242
271
  else
243
272
  fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
@@ -6,11 +6,12 @@
6
6
  The version of the OpenAPI document: v1
7
7
  Contact: developers@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.2.1
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module Patch
16
17
  class Allocation
@@ -32,6 +33,11 @@ module Patch
32
33
  }
33
34
  end
34
35
 
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
35
41
  # Attribute type mapping.
36
42
  def self.openapi_types
37
43
  {
@@ -41,13 +47,13 @@ module Patch
41
47
  }
42
48
  end
43
49
 
44
- # Set with nullable attributes.
50
+ # List of attributes with nullable: true
45
51
  def self.openapi_nullable
46
- nullable_properties = Set.new
47
-
48
- nullable_properties
52
+ Set.new([
53
+ ])
49
54
  end
50
55
 
56
+
51
57
  # Allows models with corresponding API classes to delegate API operations to those API classes
52
58
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
53
59
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -150,7 +156,9 @@ module Patch
150
156
  def build_from_hash(attributes)
151
157
  return nil unless attributes.is_a?(Hash)
152
158
  self.class.openapi_types.each_pair do |key, type|
153
- if type =~ /\AArray<(.*)>/i
159
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
160
+ self.send("#{key}=", nil)
161
+ elsif type =~ /\AArray<(.*)>/i
154
162
  # check to ensure the input is an array given that the attribute
155
163
  # is documented as an array but the input is not
156
164
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -158,7 +166,7 @@ module Patch
158
166
  end
159
167
  elsif !attributes[self.class.attribute_map[key]].nil?
160
168
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
161
- end # or else data not found in attributes(hash), not an issue as the data can be optional
169
+ end
162
170
  end
163
171
 
164
172
  self
@@ -170,8 +178,8 @@ module Patch
170
178
  # @return [Object] Deserialized data
171
179
  def _deserialize(type, value)
172
180
  case type.to_sym
173
- when :DateTime
174
- DateTime.parse(value)
181
+ when :Time
182
+ Time.parse(value)
175
183
  when :Date
176
184
  Date.parse(value)
177
185
  when :String
@@ -201,7 +209,9 @@ module Patch
201
209
  end
202
210
  end
203
211
  else # model
204
- Patch.const_get(type).build_from_hash(value)
212
+ # models (e.g. Pet) or oneOf
213
+ klass = Patch.const_get(type)
214
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
205
215
  end
206
216
  end
207
217
 
@@ -227,7 +237,7 @@ module Patch
227
237
  is_nullable = self.class.openapi_nullable.include?(attr)
228
238
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
229
239
  end
230
-
240
+
231
241
  hash[param] = _to_hash(value)
232
242
  end
233
243
  hash
@@ -6,11 +6,12 @@
6
6
  The version of the OpenAPI document: v1
7
7
  Contact: developers@usepatch.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.2.1
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module Patch
16
17
  class CreateBitcoinEstimateRequest
@@ -32,6 +33,11 @@ module Patch
32
33
  }
33
34
  end
34
35
 
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
35
41
  # Attribute type mapping.
36
42
  def self.openapi_types
37
43
  {
@@ -42,21 +48,17 @@ module Patch
42
48
  }
43
49
  end
44
50
 
45
- # Set with nullable attributes.
51
+ # List of attributes with nullable: true
46
52
  def self.openapi_nullable
47
- nullable_properties = Set.new
48
-
49
- nullable_properties.add("timestamp")
50
-
51
- nullable_properties.add("transaction_value_btc_sats")
52
-
53
- nullable_properties.add("project_id")
54
-
55
- nullable_properties.add("create_order")
56
-
57
- nullable_properties
53
+ Set.new([
54
+ :'timestamp',
55
+ :'transaction_value_btc_sats',
56
+ :'project_id',
57
+ :'create_order'
58
+ ])
58
59
  end
59
60
 
61
+
60
62
  # Allows models with corresponding API classes to delegate API operations to those API classes
61
63
  # Exposes Model.operation_id which delegates to ModelsApi.new.operation_id
62
64
  # Eg. Order.create_order delegates to OrdersApi.new.create_order
@@ -149,7 +151,9 @@ module Patch
149
151
  def build_from_hash(attributes)
150
152
  return nil unless attributes.is_a?(Hash)
151
153
  self.class.openapi_types.each_pair do |key, type|
152
- if type =~ /\AArray<(.*)>/i
154
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
155
+ self.send("#{key}=", nil)
156
+ elsif type =~ /\AArray<(.*)>/i
153
157
  # check to ensure the input is an array given that the attribute
154
158
  # is documented as an array but the input is not
155
159
  if attributes[self.class.attribute_map[key]].is_a?(Array)
@@ -157,7 +161,7 @@ module Patch
157
161
  end
158
162
  elsif !attributes[self.class.attribute_map[key]].nil?
159
163
  self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
160
- end # or else data not found in attributes(hash), not an issue as the data can be optional
164
+ end
161
165
  end
162
166
 
163
167
  self
@@ -169,8 +173,8 @@ module Patch
169
173
  # @return [Object] Deserialized data
170
174
  def _deserialize(type, value)
171
175
  case type.to_sym
172
- when :DateTime
173
- DateTime.parse(value)
176
+ when :Time
177
+ Time.parse(value)
174
178
  when :Date
175
179
  Date.parse(value)
176
180
  when :String
@@ -200,7 +204,9 @@ module Patch
200
204
  end
201
205
  end
202
206
  else # model
203
- Patch.const_get(type).build_from_hash(value)
207
+ # models (e.g. Pet) or oneOf
208
+ klass = Patch.const_get(type)
209
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
204
210
  end
205
211
  end
206
212
 
@@ -226,7 +232,7 @@ module Patch
226
232
  is_nullable = self.class.openapi_nullable.include?(attr)
227
233
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
228
234
  end
229
-
235
+
230
236
  hash[param] = _to_hash(value)
231
237
  end
232
238
  hash