tensors-ruby 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +154 -0
  4. data/lib/tensors-ruby/api/auth_api.rb +387 -0
  5. data/lib/tensors-ruby/api/civit_ai_api.rb +85 -0
  6. data/lib/tensors-ruby/api/comfy_uiapi_api.rb +582 -0
  7. data/lib/tensors-ruby/api/database_api.rb +655 -0
  8. data/lib/tensors-ruby/api/default_api.rb +77 -0
  9. data/lib/tensors-ruby/api/download_api.rb +210 -0
  10. data/lib/tensors-ruby/api/gallery_api.rb +416 -0
  11. data/lib/tensors-ruby/api/search_api.rb +129 -0
  12. data/lib/tensors-ruby/api_client.rb +441 -0
  13. data/lib/tensors-ruby/api_error.rb +58 -0
  14. data/lib/tensors-ruby/api_model_base.rb +88 -0
  15. data/lib/tensors-ruby/configuration.rb +399 -0
  16. data/lib/tensors-ruby/models/cache_request.rb +165 -0
  17. data/lib/tensors-ruby/models/download_request.rb +179 -0
  18. data/lib/tensors-ruby/models/generate_request.rb +444 -0
  19. data/lib/tensors-ruby/models/generate_response.rb +213 -0
  20. data/lib/tensors-ruby/models/http_validation_error.rb +149 -0
  21. data/lib/tensors-ruby/models/location_inner.rb +103 -0
  22. data/lib/tensors-ruby/models/metadata_update.rb +181 -0
  23. data/lib/tensors-ruby/models/models_response.rb +205 -0
  24. data/lib/tensors-ruby/models/provider.rb +41 -0
  25. data/lib/tensors-ruby/models/queue_status_response.rb +161 -0
  26. data/lib/tensors-ruby/models/scan_request.rb +165 -0
  27. data/lib/tensors-ruby/models/sort_order.rb +41 -0
  28. data/lib/tensors-ruby/models/system_stats_response.rb +161 -0
  29. data/lib/tensors-ruby/models/validation_error.rb +237 -0
  30. data/lib/tensors-ruby/models/workflow_request.rb +168 -0
  31. data/lib/tensors-ruby/models/workflow_response.rb +222 -0
  32. data/lib/tensors-ruby/version.rb +15 -0
  33. data/lib/tensors-ruby.rb +64 -0
  34. data/spec/api/auth_api_spec.rb +109 -0
  35. data/spec/api/civit_ai_api_spec.rb +47 -0
  36. data/spec/api/comfy_uiapi_api_spec.rb +141 -0
  37. data/spec/api/database_api_spec.rb +155 -0
  38. data/spec/api/default_api_spec.rb +45 -0
  39. data/spec/api/download_api_spec.rb +70 -0
  40. data/spec/api/gallery_api_spec.rb +109 -0
  41. data/spec/api/search_api_spec.rb +60 -0
  42. data/spec/models/cache_request_spec.rb +36 -0
  43. data/spec/models/download_request_spec.rb +54 -0
  44. data/spec/models/generate_request_spec.rb +108 -0
  45. data/spec/models/generate_response_spec.rb +54 -0
  46. data/spec/models/http_validation_error_spec.rb +36 -0
  47. data/spec/models/location_inner_spec.rb +21 -0
  48. data/spec/models/metadata_update_spec.rb +54 -0
  49. data/spec/models/models_response_spec.rb +66 -0
  50. data/spec/models/provider_spec.rb +30 -0
  51. data/spec/models/queue_status_response_spec.rb +42 -0
  52. data/spec/models/scan_request_spec.rb +36 -0
  53. data/spec/models/sort_order_spec.rb +30 -0
  54. data/spec/models/system_stats_response_spec.rb +42 -0
  55. data/spec/models/validation_error_spec.rb +60 -0
  56. data/spec/models/workflow_request_spec.rb +36 -0
  57. data/spec/models/workflow_response_spec.rb +60 -0
  58. data/spec/spec_helper.rb +111 -0
  59. data/tensors-ruby.gemspec +41 -0
  60. metadata +194 -0
@@ -0,0 +1,179 @@
1
+ =begin
2
+ #tensors
3
+
4
+ #API for CivitAI model management and image gallery
5
+
6
+ The version of the OpenAPI document: 0.1.18
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.21.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TensorsApi
17
+ # Request body for downloading a model.
18
+ class DownloadRequest < ApiModelBase
19
+ attr_accessor :version_id
20
+
21
+ attr_accessor :model_id
22
+
23
+ attr_accessor :hash
24
+
25
+ attr_accessor :output_dir
26
+
27
+ # Attribute mapping from ruby-style variable name to JSON key.
28
+ def self.attribute_map
29
+ {
30
+ :'version_id' => :'version_id',
31
+ :'model_id' => :'model_id',
32
+ :'hash' => :'hash',
33
+ :'output_dir' => :'output_dir'
34
+ }
35
+ end
36
+
37
+ # Returns attribute mapping this model knows about
38
+ def self.acceptable_attribute_map
39
+ attribute_map
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ acceptable_attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'version_id' => :'Integer',
51
+ :'model_id' => :'Integer',
52
+ :'hash' => :'String',
53
+ :'output_dir' => :'String'
54
+ }
55
+ end
56
+
57
+ # List of attributes with nullable: true
58
+ def self.openapi_nullable
59
+ Set.new([
60
+ :'version_id',
61
+ :'model_id',
62
+ :'hash',
63
+ :'output_dir'
64
+ ])
65
+ end
66
+
67
+ # Initializes the object
68
+ # @param [Hash] attributes Model attributes in the form of hash
69
+ def initialize(attributes = {})
70
+ if (!attributes.is_a?(Hash))
71
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TensorsApi::DownloadRequest` initialize method"
72
+ end
73
+
74
+ # check to see if the attribute exists and convert string to symbol for hash key
75
+ acceptable_attribute_map = self.class.acceptable_attribute_map
76
+ attributes = attributes.each_with_object({}) { |(k, v), h|
77
+ if (!acceptable_attribute_map.key?(k.to_sym))
78
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TensorsApi::DownloadRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
79
+ end
80
+ h[k.to_sym] = v
81
+ }
82
+
83
+ if attributes.key?(:'version_id')
84
+ self.version_id = attributes[:'version_id']
85
+ end
86
+
87
+ if attributes.key?(:'model_id')
88
+ self.model_id = attributes[:'model_id']
89
+ end
90
+
91
+ if attributes.key?(:'hash')
92
+ self.hash = attributes[:'hash']
93
+ end
94
+
95
+ if attributes.key?(:'output_dir')
96
+ self.output_dir = attributes[:'output_dir']
97
+ end
98
+ end
99
+
100
+ # Show invalid properties with the reasons. Usually used together with valid?
101
+ # @return Array for valid properties with the reasons
102
+ def list_invalid_properties
103
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
104
+ invalid_properties = Array.new
105
+ invalid_properties
106
+ end
107
+
108
+ # Check to see if the all the properties in the model are valid
109
+ # @return true if the model is valid
110
+ def valid?
111
+ warn '[DEPRECATED] the `valid?` method is obsolete'
112
+ true
113
+ end
114
+
115
+ # Checks equality by comparing each attribute.
116
+ # @param [Object] Object to be compared
117
+ def ==(o)
118
+ return true if self.equal?(o)
119
+ self.class == o.class &&
120
+ version_id == o.version_id &&
121
+ model_id == o.model_id &&
122
+ hash == o.hash &&
123
+ output_dir == o.output_dir
124
+ end
125
+
126
+ # @see the `==` method
127
+ # @param [Object] Object to be compared
128
+ def eql?(o)
129
+ self == o
130
+ end
131
+
132
+ # Calculates hash code according to all attributes.
133
+ # @return [Integer] Hash code
134
+ def hash
135
+ [version_id, model_id, hash, output_dir].hash
136
+ end
137
+
138
+ # Builds the object from hash
139
+ # @param [Hash] attributes Model attributes in the form of hash
140
+ # @return [Object] Returns the model itself
141
+ def self.build_from_hash(attributes)
142
+ return nil unless attributes.is_a?(Hash)
143
+ attributes = attributes.transform_keys(&:to_sym)
144
+ transformed_hash = {}
145
+ openapi_types.each_pair do |key, type|
146
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
147
+ transformed_hash["#{key}"] = nil
148
+ elsif type =~ /\AArray<(.*)>/i
149
+ # check to ensure the input is an array given that the attribute
150
+ # is documented as an array but the input is not
151
+ if attributes[attribute_map[key]].is_a?(Array)
152
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
153
+ end
154
+ elsif !attributes[attribute_map[key]].nil?
155
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
156
+ end
157
+ end
158
+ new(transformed_hash)
159
+ end
160
+
161
+ # Returns the object in the form of hash
162
+ # @return [Hash] Returns the object in the form of hash
163
+ def to_hash
164
+ hash = {}
165
+ self.class.attribute_map.each_pair do |attr, param|
166
+ value = self.send(attr)
167
+ if value.nil?
168
+ is_nullable = self.class.openapi_nullable.include?(attr)
169
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
170
+ end
171
+
172
+ hash[param] = _to_hash(value)
173
+ end
174
+ hash
175
+ end
176
+
177
+ end
178
+
179
+ end
@@ -0,0 +1,444 @@
1
+ =begin
2
+ #tensors
3
+
4
+ #API for CivitAI model management and image gallery
5
+
6
+ The version of the OpenAPI document: 0.1.18
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.21.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module TensorsApi
17
+ # Request body for text-to-image generation.
18
+ class GenerateRequest < ApiModelBase
19
+ # Positive prompt text
20
+ attr_accessor :prompt
21
+
22
+ # Negative prompt text
23
+ attr_accessor :negative_prompt
24
+
25
+ attr_accessor :model
26
+
27
+ # Image width
28
+ attr_accessor :width
29
+
30
+ # Image height
31
+ attr_accessor :height
32
+
33
+ # Sampling steps
34
+ attr_accessor :steps
35
+
36
+ # CFG scale
37
+ attr_accessor :cfg
38
+
39
+ # Random seed (-1 for random)
40
+ attr_accessor :seed
41
+
42
+ # Sampler name
43
+ attr_accessor :sampler
44
+
45
+ # Scheduler name
46
+ attr_accessor :scheduler
47
+
48
+ attr_accessor :vae
49
+
50
+ attr_accessor :lora_name
51
+
52
+ # LoRA strength
53
+ attr_accessor :lora_strength
54
+
55
+ # Attribute mapping from ruby-style variable name to JSON key.
56
+ def self.attribute_map
57
+ {
58
+ :'prompt' => :'prompt',
59
+ :'negative_prompt' => :'negative_prompt',
60
+ :'model' => :'model',
61
+ :'width' => :'width',
62
+ :'height' => :'height',
63
+ :'steps' => :'steps',
64
+ :'cfg' => :'cfg',
65
+ :'seed' => :'seed',
66
+ :'sampler' => :'sampler',
67
+ :'scheduler' => :'scheduler',
68
+ :'vae' => :'vae',
69
+ :'lora_name' => :'lora_name',
70
+ :'lora_strength' => :'lora_strength'
71
+ }
72
+ end
73
+
74
+ # Returns attribute mapping this model knows about
75
+ def self.acceptable_attribute_map
76
+ attribute_map
77
+ end
78
+
79
+ # Returns all the JSON keys this model knows about
80
+ def self.acceptable_attributes
81
+ acceptable_attribute_map.values
82
+ end
83
+
84
+ # Attribute type mapping.
85
+ def self.openapi_types
86
+ {
87
+ :'prompt' => :'String',
88
+ :'negative_prompt' => :'String',
89
+ :'model' => :'String',
90
+ :'width' => :'Integer',
91
+ :'height' => :'Integer',
92
+ :'steps' => :'Integer',
93
+ :'cfg' => :'Float',
94
+ :'seed' => :'Integer',
95
+ :'sampler' => :'String',
96
+ :'scheduler' => :'String',
97
+ :'vae' => :'String',
98
+ :'lora_name' => :'String',
99
+ :'lora_strength' => :'Float'
100
+ }
101
+ end
102
+
103
+ # List of attributes with nullable: true
104
+ def self.openapi_nullable
105
+ Set.new([
106
+ :'model',
107
+ :'vae',
108
+ :'lora_name',
109
+ ])
110
+ end
111
+
112
+ # Initializes the object
113
+ # @param [Hash] attributes Model attributes in the form of hash
114
+ def initialize(attributes = {})
115
+ if (!attributes.is_a?(Hash))
116
+ fail ArgumentError, "The input argument (attributes) must be a hash in `TensorsApi::GenerateRequest` initialize method"
117
+ end
118
+
119
+ # check to see if the attribute exists and convert string to symbol for hash key
120
+ acceptable_attribute_map = self.class.acceptable_attribute_map
121
+ attributes = attributes.each_with_object({}) { |(k, v), h|
122
+ if (!acceptable_attribute_map.key?(k.to_sym))
123
+ fail ArgumentError, "`#{k}` is not a valid attribute in `TensorsApi::GenerateRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
124
+ end
125
+ h[k.to_sym] = v
126
+ }
127
+
128
+ if attributes.key?(:'prompt')
129
+ self.prompt = attributes[:'prompt']
130
+ else
131
+ self.prompt = nil
132
+ end
133
+
134
+ if attributes.key?(:'negative_prompt')
135
+ self.negative_prompt = attributes[:'negative_prompt']
136
+ else
137
+ self.negative_prompt = ''
138
+ end
139
+
140
+ if attributes.key?(:'model')
141
+ self.model = attributes[:'model']
142
+ end
143
+
144
+ if attributes.key?(:'width')
145
+ self.width = attributes[:'width']
146
+ else
147
+ self.width = 1024
148
+ end
149
+
150
+ if attributes.key?(:'height')
151
+ self.height = attributes[:'height']
152
+ else
153
+ self.height = 1024
154
+ end
155
+
156
+ if attributes.key?(:'steps')
157
+ self.steps = attributes[:'steps']
158
+ else
159
+ self.steps = 20
160
+ end
161
+
162
+ if attributes.key?(:'cfg')
163
+ self.cfg = attributes[:'cfg']
164
+ else
165
+ self.cfg = 7.0
166
+ end
167
+
168
+ if attributes.key?(:'seed')
169
+ self.seed = attributes[:'seed']
170
+ else
171
+ self.seed = -1
172
+ end
173
+
174
+ if attributes.key?(:'sampler')
175
+ self.sampler = attributes[:'sampler']
176
+ else
177
+ self.sampler = 'euler'
178
+ end
179
+
180
+ if attributes.key?(:'scheduler')
181
+ self.scheduler = attributes[:'scheduler']
182
+ else
183
+ self.scheduler = 'normal'
184
+ end
185
+
186
+ if attributes.key?(:'vae')
187
+ self.vae = attributes[:'vae']
188
+ end
189
+
190
+ if attributes.key?(:'lora_name')
191
+ self.lora_name = attributes[:'lora_name']
192
+ end
193
+
194
+ if attributes.key?(:'lora_strength')
195
+ self.lora_strength = attributes[:'lora_strength']
196
+ else
197
+ self.lora_strength = 0.8
198
+ end
199
+ end
200
+
201
+ # Show invalid properties with the reasons. Usually used together with valid?
202
+ # @return Array for valid properties with the reasons
203
+ def list_invalid_properties
204
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
205
+ invalid_properties = Array.new
206
+ if @prompt.nil?
207
+ invalid_properties.push('invalid value for "prompt", prompt cannot be nil.')
208
+ end
209
+
210
+ if !@width.nil? && @width > 4096
211
+ invalid_properties.push('invalid value for "width", must be smaller than or equal to 4096.')
212
+ end
213
+
214
+ if !@width.nil? && @width < 64
215
+ invalid_properties.push('invalid value for "width", must be greater than or equal to 64.')
216
+ end
217
+
218
+ if !@height.nil? && @height > 4096
219
+ invalid_properties.push('invalid value for "height", must be smaller than or equal to 4096.')
220
+ end
221
+
222
+ if !@height.nil? && @height < 64
223
+ invalid_properties.push('invalid value for "height", must be greater than or equal to 64.')
224
+ end
225
+
226
+ if !@steps.nil? && @steps > 150
227
+ invalid_properties.push('invalid value for "steps", must be smaller than or equal to 150.')
228
+ end
229
+
230
+ if !@steps.nil? && @steps < 1
231
+ invalid_properties.push('invalid value for "steps", must be greater than or equal to 1.')
232
+ end
233
+
234
+ if !@cfg.nil? && @cfg > 30.0
235
+ invalid_properties.push('invalid value for "cfg", must be smaller than or equal to 30.0.')
236
+ end
237
+
238
+ if !@cfg.nil? && @cfg < 1.0
239
+ invalid_properties.push('invalid value for "cfg", must be greater than or equal to 1.0.')
240
+ end
241
+
242
+ if !@lora_strength.nil? && @lora_strength > 2.0
243
+ invalid_properties.push('invalid value for "lora_strength", must be smaller than or equal to 2.0.')
244
+ end
245
+
246
+ if !@lora_strength.nil? && @lora_strength < 0.0
247
+ invalid_properties.push('invalid value for "lora_strength", must be greater than or equal to 0.0.')
248
+ end
249
+
250
+ invalid_properties
251
+ end
252
+
253
+ # Check to see if the all the properties in the model are valid
254
+ # @return true if the model is valid
255
+ def valid?
256
+ warn '[DEPRECATED] the `valid?` method is obsolete'
257
+ return false if @prompt.nil?
258
+ return false if !@width.nil? && @width > 4096
259
+ return false if !@width.nil? && @width < 64
260
+ return false if !@height.nil? && @height > 4096
261
+ return false if !@height.nil? && @height < 64
262
+ return false if !@steps.nil? && @steps > 150
263
+ return false if !@steps.nil? && @steps < 1
264
+ return false if !@cfg.nil? && @cfg > 30.0
265
+ return false if !@cfg.nil? && @cfg < 1.0
266
+ return false if !@lora_strength.nil? && @lora_strength > 2.0
267
+ return false if !@lora_strength.nil? && @lora_strength < 0.0
268
+ true
269
+ end
270
+
271
+ # Custom attribute writer method with validation
272
+ # @param [Object] prompt Value to be assigned
273
+ def prompt=(prompt)
274
+ if prompt.nil?
275
+ fail ArgumentError, 'prompt cannot be nil'
276
+ end
277
+
278
+ @prompt = prompt
279
+ end
280
+
281
+ # Custom attribute writer method with validation
282
+ # @param [Object] width Value to be assigned
283
+ def width=(width)
284
+ if width.nil?
285
+ fail ArgumentError, 'width cannot be nil'
286
+ end
287
+
288
+ if width > 4096
289
+ fail ArgumentError, 'invalid value for "width", must be smaller than or equal to 4096.'
290
+ end
291
+
292
+ if width < 64
293
+ fail ArgumentError, 'invalid value for "width", must be greater than or equal to 64.'
294
+ end
295
+
296
+ @width = width
297
+ end
298
+
299
+ # Custom attribute writer method with validation
300
+ # @param [Object] height Value to be assigned
301
+ def height=(height)
302
+ if height.nil?
303
+ fail ArgumentError, 'height cannot be nil'
304
+ end
305
+
306
+ if height > 4096
307
+ fail ArgumentError, 'invalid value for "height", must be smaller than or equal to 4096.'
308
+ end
309
+
310
+ if height < 64
311
+ fail ArgumentError, 'invalid value for "height", must be greater than or equal to 64.'
312
+ end
313
+
314
+ @height = height
315
+ end
316
+
317
+ # Custom attribute writer method with validation
318
+ # @param [Object] steps Value to be assigned
319
+ def steps=(steps)
320
+ if steps.nil?
321
+ fail ArgumentError, 'steps cannot be nil'
322
+ end
323
+
324
+ if steps > 150
325
+ fail ArgumentError, 'invalid value for "steps", must be smaller than or equal to 150.'
326
+ end
327
+
328
+ if steps < 1
329
+ fail ArgumentError, 'invalid value for "steps", must be greater than or equal to 1.'
330
+ end
331
+
332
+ @steps = steps
333
+ end
334
+
335
+ # Custom attribute writer method with validation
336
+ # @param [Object] cfg Value to be assigned
337
+ def cfg=(cfg)
338
+ if cfg.nil?
339
+ fail ArgumentError, 'cfg cannot be nil'
340
+ end
341
+
342
+ if cfg > 30.0
343
+ fail ArgumentError, 'invalid value for "cfg", must be smaller than or equal to 30.0.'
344
+ end
345
+
346
+ if cfg < 1.0
347
+ fail ArgumentError, 'invalid value for "cfg", must be greater than or equal to 1.0.'
348
+ end
349
+
350
+ @cfg = cfg
351
+ end
352
+
353
+ # Custom attribute writer method with validation
354
+ # @param [Object] lora_strength Value to be assigned
355
+ def lora_strength=(lora_strength)
356
+ if lora_strength.nil?
357
+ fail ArgumentError, 'lora_strength cannot be nil'
358
+ end
359
+
360
+ if lora_strength > 2.0
361
+ fail ArgumentError, 'invalid value for "lora_strength", must be smaller than or equal to 2.0.'
362
+ end
363
+
364
+ if lora_strength < 0.0
365
+ fail ArgumentError, 'invalid value for "lora_strength", must be greater than or equal to 0.0.'
366
+ end
367
+
368
+ @lora_strength = lora_strength
369
+ end
370
+
371
+ # Checks equality by comparing each attribute.
372
+ # @param [Object] Object to be compared
373
+ def ==(o)
374
+ return true if self.equal?(o)
375
+ self.class == o.class &&
376
+ prompt == o.prompt &&
377
+ negative_prompt == o.negative_prompt &&
378
+ model == o.model &&
379
+ width == o.width &&
380
+ height == o.height &&
381
+ steps == o.steps &&
382
+ cfg == o.cfg &&
383
+ seed == o.seed &&
384
+ sampler == o.sampler &&
385
+ scheduler == o.scheduler &&
386
+ vae == o.vae &&
387
+ lora_name == o.lora_name &&
388
+ lora_strength == o.lora_strength
389
+ end
390
+
391
+ # @see the `==` method
392
+ # @param [Object] Object to be compared
393
+ def eql?(o)
394
+ self == o
395
+ end
396
+
397
+ # Calculates hash code according to all attributes.
398
+ # @return [Integer] Hash code
399
+ def hash
400
+ [prompt, negative_prompt, model, width, height, steps, cfg, seed, sampler, scheduler, vae, lora_name, lora_strength].hash
401
+ end
402
+
403
+ # Builds the object from hash
404
+ # @param [Hash] attributes Model attributes in the form of hash
405
+ # @return [Object] Returns the model itself
406
+ def self.build_from_hash(attributes)
407
+ return nil unless attributes.is_a?(Hash)
408
+ attributes = attributes.transform_keys(&:to_sym)
409
+ transformed_hash = {}
410
+ openapi_types.each_pair do |key, type|
411
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
412
+ transformed_hash["#{key}"] = nil
413
+ elsif type =~ /\AArray<(.*)>/i
414
+ # check to ensure the input is an array given that the attribute
415
+ # is documented as an array but the input is not
416
+ if attributes[attribute_map[key]].is_a?(Array)
417
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
418
+ end
419
+ elsif !attributes[attribute_map[key]].nil?
420
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
421
+ end
422
+ end
423
+ new(transformed_hash)
424
+ end
425
+
426
+ # Returns the object in the form of hash
427
+ # @return [Hash] Returns the object in the form of hash
428
+ def to_hash
429
+ hash = {}
430
+ self.class.attribute_map.each_pair do |attr, param|
431
+ value = self.send(attr)
432
+ if value.nil?
433
+ is_nullable = self.class.openapi_nullable.include?(attr)
434
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
435
+ end
436
+
437
+ hash[param] = _to_hash(value)
438
+ end
439
+ hash
440
+ end
441
+
442
+ end
443
+
444
+ end