browserup_mitmproxy_client 1.1

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 (76) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +68 -0
  4. data/README.md +119 -0
  5. data/Rakefile +10 -0
  6. data/browserup_mitmproxy_client.gemspec +38 -0
  7. data/docs/BrowserUpProxyApi.md +657 -0
  8. data/docs/Counter.md +20 -0
  9. data/docs/Entry.md +38 -0
  10. data/docs/EntryRequest.md +36 -0
  11. data/docs/EntryRequestCookies.md +32 -0
  12. data/docs/EntryRequestQueryString.md +22 -0
  13. data/docs/EntryResponse.md +36 -0
  14. data/docs/EntryResponseContent.md +28 -0
  15. data/docs/EntryTimings.md +32 -0
  16. data/docs/Error.md +20 -0
  17. data/docs/Har.md +18 -0
  18. data/docs/HarLog.md +28 -0
  19. data/docs/HarLogCreator.md +22 -0
  20. data/docs/Header.md +22 -0
  21. data/docs/MatchCriteria.md +44 -0
  22. data/docs/NameValuePair.md +20 -0
  23. data/docs/Page.md +32 -0
  24. data/docs/PagePageTimings.md +22 -0
  25. data/docs/VerifyResult.md +22 -0
  26. data/docs/WebSocketMessage.md +24 -0
  27. data/git_push.sh +58 -0
  28. data/lib/browserup_mitmproxy_client/api/browser_up_proxy_api.rb +689 -0
  29. data/lib/browserup_mitmproxy_client/api_client.rb +389 -0
  30. data/lib/browserup_mitmproxy_client/api_error.rb +57 -0
  31. data/lib/browserup_mitmproxy_client/configuration.rb +279 -0
  32. data/lib/browserup_mitmproxy_client/models/counter.rb +239 -0
  33. data/lib/browserup_mitmproxy_client/models/entry.rb +359 -0
  34. data/lib/browserup_mitmproxy_client/models/entry_request.rb +346 -0
  35. data/lib/browserup_mitmproxy_client/models/entry_request_cookies.rb +291 -0
  36. data/lib/browserup_mitmproxy_client/models/entry_request_query_string.rb +246 -0
  37. data/lib/browserup_mitmproxy_client/models/entry_response.rb +348 -0
  38. data/lib/browserup_mitmproxy_client/models/entry_response_content.rb +273 -0
  39. data/lib/browserup_mitmproxy_client/models/entry_timings.rb +463 -0
  40. data/lib/browserup_mitmproxy_client/models/error.rb +229 -0
  41. data/lib/browserup_mitmproxy_client/models/har.rb +223 -0
  42. data/lib/browserup_mitmproxy_client/models/har_log.rb +287 -0
  43. data/lib/browserup_mitmproxy_client/models/har_log_creator.rb +246 -0
  44. data/lib/browserup_mitmproxy_client/models/header.rb +246 -0
  45. data/lib/browserup_mitmproxy_client/models/match_criteria.rb +346 -0
  46. data/lib/browserup_mitmproxy_client/models/name_value_pair.rb +229 -0
  47. data/lib/browserup_mitmproxy_client/models/page.rb +312 -0
  48. data/lib/browserup_mitmproxy_client/models/page_page_timings.rb +288 -0
  49. data/lib/browserup_mitmproxy_client/models/verify_result.rb +254 -0
  50. data/lib/browserup_mitmproxy_client/models/web_socket_message.rb +265 -0
  51. data/lib/browserup_mitmproxy_client/version.rb +15 -0
  52. data/lib/browserup_mitmproxy_client.rb +59 -0
  53. data/spec/api/browser_up_proxy_api_spec.rb +148 -0
  54. data/spec/api_client_spec.rb +226 -0
  55. data/spec/configuration_spec.rb +42 -0
  56. data/spec/models/counter_spec.rb +40 -0
  57. data/spec/models/entry_request_cookies_spec.rb +76 -0
  58. data/spec/models/entry_request_query_string_spec.rb +46 -0
  59. data/spec/models/entry_request_spec.rb +88 -0
  60. data/spec/models/entry_response_content_spec.rb +64 -0
  61. data/spec/models/entry_response_spec.rb +88 -0
  62. data/spec/models/entry_spec.rb +94 -0
  63. data/spec/models/entry_timings_spec.rb +76 -0
  64. data/spec/models/error_spec.rb +40 -0
  65. data/spec/models/har_log_creator_spec.rb +46 -0
  66. data/spec/models/har_log_spec.rb +64 -0
  67. data/spec/models/har_spec.rb +34 -0
  68. data/spec/models/header_spec.rb +46 -0
  69. data/spec/models/match_criteria_spec.rb +112 -0
  70. data/spec/models/name_value_pair_spec.rb +40 -0
  71. data/spec/models/page_page_timings_spec.rb +46 -0
  72. data/spec/models/page_spec.rb +76 -0
  73. data/spec/models/verify_result_spec.rb +46 -0
  74. data/spec/models/web_socket_message_spec.rb +52 -0
  75. data/spec/spec_helper.rb +111 -0
  76. metadata +181 -0
@@ -0,0 +1,348 @@
1
+ =begin
2
+ #BrowserUp MitmProxy
3
+
4
+ #___ This is the REST API for controlling the BrowserUp MitmProxy. The BrowserUp MitmProxy is a swiss army knife for automated testing that captures HTTP traffic in HAR files. It is also useful for Selenium/Cypress tests. ___
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BrowserupMitmProxy
17
+ class EntryResponse
18
+ attr_accessor :status
19
+
20
+ attr_accessor :status_text
21
+
22
+ attr_accessor :http_version
23
+
24
+ attr_accessor :cookies
25
+
26
+ attr_accessor :headers
27
+
28
+ attr_accessor :content
29
+
30
+ attr_accessor :redirect_url
31
+
32
+ attr_accessor :headers_size
33
+
34
+ attr_accessor :body_size
35
+
36
+ attr_accessor :comment
37
+
38
+ # Attribute mapping from ruby-style variable name to JSON key.
39
+ def self.attribute_map
40
+ {
41
+ :'status' => :'status',
42
+ :'status_text' => :'statusText',
43
+ :'http_version' => :'httpVersion',
44
+ :'cookies' => :'cookies',
45
+ :'headers' => :'headers',
46
+ :'content' => :'content',
47
+ :'redirect_url' => :'redirectURL',
48
+ :'headers_size' => :'headersSize',
49
+ :'body_size' => :'bodySize',
50
+ :'comment' => :'comment'
51
+ }
52
+ end
53
+
54
+ # Returns all the JSON keys this model knows about
55
+ def self.acceptable_attributes
56
+ attribute_map.values
57
+ end
58
+
59
+ # Attribute type mapping.
60
+ def self.openapi_types
61
+ {
62
+ :'status' => :'Integer',
63
+ :'status_text' => :'String',
64
+ :'http_version' => :'String',
65
+ :'cookies' => :'Array<EntryRequestCookies>',
66
+ :'headers' => :'Array<Header>',
67
+ :'content' => :'EntryResponseContent',
68
+ :'redirect_url' => :'String',
69
+ :'headers_size' => :'Integer',
70
+ :'body_size' => :'Integer',
71
+ :'comment' => :'String'
72
+ }
73
+ end
74
+
75
+ # List of attributes with nullable: true
76
+ def self.openapi_nullable
77
+ Set.new([
78
+ ])
79
+ end
80
+
81
+ # Initializes the object
82
+ # @param [Hash] attributes Model attributes in the form of hash
83
+ def initialize(attributes = {})
84
+ if (!attributes.is_a?(Hash))
85
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BrowserupMitmProxy::EntryResponse` initialize method"
86
+ end
87
+
88
+ # check to see if the attribute exists and convert string to symbol for hash key
89
+ attributes = attributes.each_with_object({}) { |(k, v), h|
90
+ if (!self.class.attribute_map.key?(k.to_sym))
91
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BrowserupMitmProxy::EntryResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
92
+ end
93
+ h[k.to_sym] = v
94
+ }
95
+
96
+ if attributes.key?(:'status')
97
+ self.status = attributes[:'status']
98
+ end
99
+
100
+ if attributes.key?(:'status_text')
101
+ self.status_text = attributes[:'status_text']
102
+ end
103
+
104
+ if attributes.key?(:'http_version')
105
+ self.http_version = attributes[:'http_version']
106
+ end
107
+
108
+ if attributes.key?(:'cookies')
109
+ if (value = attributes[:'cookies']).is_a?(Array)
110
+ self.cookies = value
111
+ end
112
+ end
113
+
114
+ if attributes.key?(:'headers')
115
+ if (value = attributes[:'headers']).is_a?(Array)
116
+ self.headers = value
117
+ end
118
+ end
119
+
120
+ if attributes.key?(:'content')
121
+ self.content = attributes[:'content']
122
+ end
123
+
124
+ if attributes.key?(:'redirect_url')
125
+ self.redirect_url = attributes[:'redirect_url']
126
+ end
127
+
128
+ if attributes.key?(:'headers_size')
129
+ self.headers_size = attributes[:'headers_size']
130
+ end
131
+
132
+ if attributes.key?(:'body_size')
133
+ self.body_size = attributes[:'body_size']
134
+ end
135
+
136
+ if attributes.key?(:'comment')
137
+ self.comment = attributes[:'comment']
138
+ end
139
+ end
140
+
141
+ # Show invalid properties with the reasons. Usually used together with valid?
142
+ # @return Array for valid properties with the reasons
143
+ def list_invalid_properties
144
+ invalid_properties = Array.new
145
+ if @status.nil?
146
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
147
+ end
148
+
149
+ if @status_text.nil?
150
+ invalid_properties.push('invalid value for "status_text", status_text cannot be nil.')
151
+ end
152
+
153
+ if @http_version.nil?
154
+ invalid_properties.push('invalid value for "http_version", http_version cannot be nil.')
155
+ end
156
+
157
+ if @cookies.nil?
158
+ invalid_properties.push('invalid value for "cookies", cookies cannot be nil.')
159
+ end
160
+
161
+ if @headers.nil?
162
+ invalid_properties.push('invalid value for "headers", headers cannot be nil.')
163
+ end
164
+
165
+ if @content.nil?
166
+ invalid_properties.push('invalid value for "content", content cannot be nil.')
167
+ end
168
+
169
+ if @redirect_url.nil?
170
+ invalid_properties.push('invalid value for "redirect_url", redirect_url cannot be nil.')
171
+ end
172
+
173
+ if @headers_size.nil?
174
+ invalid_properties.push('invalid value for "headers_size", headers_size cannot be nil.')
175
+ end
176
+
177
+ if @body_size.nil?
178
+ invalid_properties.push('invalid value for "body_size", body_size cannot be nil.')
179
+ end
180
+
181
+ invalid_properties
182
+ end
183
+
184
+ # Check to see if the all the properties in the model are valid
185
+ # @return true if the model is valid
186
+ def valid?
187
+ return false if @status.nil?
188
+ return false if @status_text.nil?
189
+ return false if @http_version.nil?
190
+ return false if @cookies.nil?
191
+ return false if @headers.nil?
192
+ return false if @content.nil?
193
+ return false if @redirect_url.nil?
194
+ return false if @headers_size.nil?
195
+ return false if @body_size.nil?
196
+ true
197
+ end
198
+
199
+ # Checks equality by comparing each attribute.
200
+ # @param [Object] Object to be compared
201
+ def ==(o)
202
+ return true if self.equal?(o)
203
+ self.class == o.class &&
204
+ status == o.status &&
205
+ status_text == o.status_text &&
206
+ http_version == o.http_version &&
207
+ cookies == o.cookies &&
208
+ headers == o.headers &&
209
+ content == o.content &&
210
+ redirect_url == o.redirect_url &&
211
+ headers_size == o.headers_size &&
212
+ body_size == o.body_size &&
213
+ comment == o.comment
214
+ end
215
+
216
+ # @see the `==` method
217
+ # @param [Object] Object to be compared
218
+ def eql?(o)
219
+ self == o
220
+ end
221
+
222
+ # Calculates hash code according to all attributes.
223
+ # @return [Integer] Hash code
224
+ def hash
225
+ [status, status_text, http_version, cookies, headers, content, redirect_url, headers_size, body_size, comment].hash
226
+ end
227
+
228
+ # Builds the object from hash
229
+ # @param [Hash] attributes Model attributes in the form of hash
230
+ # @return [Object] Returns the model itself
231
+ def self.build_from_hash(attributes)
232
+ new.build_from_hash(attributes)
233
+ end
234
+
235
+ # Builds the object from hash
236
+ # @param [Hash] attributes Model attributes in the form of hash
237
+ # @return [Object] Returns the model itself
238
+ def build_from_hash(attributes)
239
+ return nil unless attributes.is_a?(Hash)
240
+ self.class.openapi_types.each_pair do |key, type|
241
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
242
+ self.send("#{key}=", nil)
243
+ elsif type =~ /\AArray<(.*)>/i
244
+ # check to ensure the input is an array given that the attribute
245
+ # is documented as an array but the input is not
246
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
247
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
248
+ end
249
+ elsif !attributes[self.class.attribute_map[key]].nil?
250
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
251
+ end
252
+ end
253
+
254
+ self
255
+ end
256
+
257
+ # Deserializes the data based on type
258
+ # @param string type Data type
259
+ # @param string value Value to be deserialized
260
+ # @return [Object] Deserialized data
261
+ def _deserialize(type, value)
262
+ case type.to_sym
263
+ when :Time
264
+ Time.parse(value)
265
+ when :Date
266
+ Date.parse(value)
267
+ when :String
268
+ value.to_s
269
+ when :Integer
270
+ value.to_i
271
+ when :Float
272
+ value.to_f
273
+ when :Boolean
274
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
275
+ true
276
+ else
277
+ false
278
+ end
279
+ when :Object
280
+ # generic object (usually a Hash), return directly
281
+ value
282
+ when /\AArray<(?<inner_type>.+)>\z/
283
+ inner_type = Regexp.last_match[:inner_type]
284
+ value.map { |v| _deserialize(inner_type, v) }
285
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
286
+ k_type = Regexp.last_match[:k_type]
287
+ v_type = Regexp.last_match[:v_type]
288
+ {}.tap do |hash|
289
+ value.each do |k, v|
290
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
291
+ end
292
+ end
293
+ else # model
294
+ # models (e.g. Pet) or oneOf
295
+ klass = BrowserupMitmProxy.const_get(type)
296
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
297
+ end
298
+ end
299
+
300
+ # Returns the string representation of the object
301
+ # @return [String] String presentation of the object
302
+ def to_s
303
+ to_hash.to_s
304
+ end
305
+
306
+ # to_body is an alias to to_hash (backward compatibility)
307
+ # @return [Hash] Returns the object in the form of hash
308
+ def to_body
309
+ to_hash
310
+ end
311
+
312
+ # Returns the object in the form of hash
313
+ # @return [Hash] Returns the object in the form of hash
314
+ def to_hash
315
+ hash = {}
316
+ self.class.attribute_map.each_pair do |attr, param|
317
+ value = self.send(attr)
318
+ if value.nil?
319
+ is_nullable = self.class.openapi_nullable.include?(attr)
320
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
321
+ end
322
+
323
+ hash[param] = _to_hash(value)
324
+ end
325
+ hash
326
+ end
327
+
328
+ # Outputs non-array value in the form of hash
329
+ # For object, use to_hash. Otherwise, just return the value
330
+ # @param [Object] value Any valid value
331
+ # @return [Hash] Returns the value in the form of hash
332
+ def _to_hash(value)
333
+ if value.is_a?(Array)
334
+ value.compact.map { |v| _to_hash(v) }
335
+ elsif value.is_a?(Hash)
336
+ {}.tap do |hash|
337
+ value.each { |k, v| hash[k] = _to_hash(v) }
338
+ end
339
+ elsif value.respond_to? :to_hash
340
+ value.to_hash
341
+ else
342
+ value
343
+ end
344
+ end
345
+
346
+ end
347
+
348
+ end
@@ -0,0 +1,273 @@
1
+ =begin
2
+ #BrowserUp MitmProxy
3
+
4
+ #___ This is the REST API for controlling the BrowserUp MitmProxy. The BrowserUp MitmProxy is a swiss army knife for automated testing that captures HTTP traffic in HAR files. It is also useful for Selenium/Cypress tests. ___
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.2.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BrowserupMitmProxy
17
+ class EntryResponseContent
18
+ attr_accessor :size
19
+
20
+ attr_accessor :compression
21
+
22
+ attr_accessor :mime_type
23
+
24
+ attr_accessor :text
25
+
26
+ attr_accessor :encoding
27
+
28
+ attr_accessor :comment
29
+
30
+ # Attribute mapping from ruby-style variable name to JSON key.
31
+ def self.attribute_map
32
+ {
33
+ :'size' => :'size',
34
+ :'compression' => :'compression',
35
+ :'mime_type' => :'mimeType',
36
+ :'text' => :'text',
37
+ :'encoding' => :'encoding',
38
+ :'comment' => :'comment'
39
+ }
40
+ end
41
+
42
+ # Returns all the JSON keys this model knows about
43
+ def self.acceptable_attributes
44
+ attribute_map.values
45
+ end
46
+
47
+ # Attribute type mapping.
48
+ def self.openapi_types
49
+ {
50
+ :'size' => :'Integer',
51
+ :'compression' => :'Integer',
52
+ :'mime_type' => :'String',
53
+ :'text' => :'String',
54
+ :'encoding' => :'String',
55
+ :'comment' => :'String'
56
+ }
57
+ end
58
+
59
+ # List of attributes with nullable: true
60
+ def self.openapi_nullable
61
+ Set.new([
62
+ ])
63
+ end
64
+
65
+ # Initializes the object
66
+ # @param [Hash] attributes Model attributes in the form of hash
67
+ def initialize(attributes = {})
68
+ if (!attributes.is_a?(Hash))
69
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BrowserupMitmProxy::EntryResponseContent` initialize method"
70
+ end
71
+
72
+ # check to see if the attribute exists and convert string to symbol for hash key
73
+ attributes = attributes.each_with_object({}) { |(k, v), h|
74
+ if (!self.class.attribute_map.key?(k.to_sym))
75
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BrowserupMitmProxy::EntryResponseContent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
76
+ end
77
+ h[k.to_sym] = v
78
+ }
79
+
80
+ if attributes.key?(:'size')
81
+ self.size = attributes[:'size']
82
+ end
83
+
84
+ if attributes.key?(:'compression')
85
+ self.compression = attributes[:'compression']
86
+ end
87
+
88
+ if attributes.key?(:'mime_type')
89
+ self.mime_type = attributes[:'mime_type']
90
+ end
91
+
92
+ if attributes.key?(:'text')
93
+ self.text = attributes[:'text']
94
+ end
95
+
96
+ if attributes.key?(:'encoding')
97
+ self.encoding = attributes[:'encoding']
98
+ end
99
+
100
+ if attributes.key?(:'comment')
101
+ self.comment = attributes[:'comment']
102
+ end
103
+ end
104
+
105
+ # Show invalid properties with the reasons. Usually used together with valid?
106
+ # @return Array for valid properties with the reasons
107
+ def list_invalid_properties
108
+ invalid_properties = Array.new
109
+ if @size.nil?
110
+ invalid_properties.push('invalid value for "size", size cannot be nil.')
111
+ end
112
+
113
+ if @mime_type.nil?
114
+ invalid_properties.push('invalid value for "mime_type", mime_type cannot be nil.')
115
+ end
116
+
117
+ invalid_properties
118
+ end
119
+
120
+ # Check to see if the all the properties in the model are valid
121
+ # @return true if the model is valid
122
+ def valid?
123
+ return false if @size.nil?
124
+ return false if @mime_type.nil?
125
+ true
126
+ end
127
+
128
+ # Checks equality by comparing each attribute.
129
+ # @param [Object] Object to be compared
130
+ def ==(o)
131
+ return true if self.equal?(o)
132
+ self.class == o.class &&
133
+ size == o.size &&
134
+ compression == o.compression &&
135
+ mime_type == o.mime_type &&
136
+ text == o.text &&
137
+ encoding == o.encoding &&
138
+ comment == o.comment
139
+ end
140
+
141
+ # @see the `==` method
142
+ # @param [Object] Object to be compared
143
+ def eql?(o)
144
+ self == o
145
+ end
146
+
147
+ # Calculates hash code according to all attributes.
148
+ # @return [Integer] Hash code
149
+ def hash
150
+ [size, compression, mime_type, text, encoding, comment].hash
151
+ end
152
+
153
+ # Builds the object from hash
154
+ # @param [Hash] attributes Model attributes in the form of hash
155
+ # @return [Object] Returns the model itself
156
+ def self.build_from_hash(attributes)
157
+ new.build_from_hash(attributes)
158
+ end
159
+
160
+ # Builds the object from hash
161
+ # @param [Hash] attributes Model attributes in the form of hash
162
+ # @return [Object] Returns the model itself
163
+ def build_from_hash(attributes)
164
+ return nil unless attributes.is_a?(Hash)
165
+ self.class.openapi_types.each_pair do |key, type|
166
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
167
+ self.send("#{key}=", nil)
168
+ elsif type =~ /\AArray<(.*)>/i
169
+ # check to ensure the input is an array given that the attribute
170
+ # is documented as an array but the input is not
171
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
172
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
173
+ end
174
+ elsif !attributes[self.class.attribute_map[key]].nil?
175
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
176
+ end
177
+ end
178
+
179
+ self
180
+ end
181
+
182
+ # Deserializes the data based on type
183
+ # @param string type Data type
184
+ # @param string value Value to be deserialized
185
+ # @return [Object] Deserialized data
186
+ def _deserialize(type, value)
187
+ case type.to_sym
188
+ when :Time
189
+ Time.parse(value)
190
+ when :Date
191
+ Date.parse(value)
192
+ when :String
193
+ value.to_s
194
+ when :Integer
195
+ value.to_i
196
+ when :Float
197
+ value.to_f
198
+ when :Boolean
199
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
200
+ true
201
+ else
202
+ false
203
+ end
204
+ when :Object
205
+ # generic object (usually a Hash), return directly
206
+ value
207
+ when /\AArray<(?<inner_type>.+)>\z/
208
+ inner_type = Regexp.last_match[:inner_type]
209
+ value.map { |v| _deserialize(inner_type, v) }
210
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
211
+ k_type = Regexp.last_match[:k_type]
212
+ v_type = Regexp.last_match[:v_type]
213
+ {}.tap do |hash|
214
+ value.each do |k, v|
215
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
216
+ end
217
+ end
218
+ else # model
219
+ # models (e.g. Pet) or oneOf
220
+ klass = BrowserupMitmProxy.const_get(type)
221
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
222
+ end
223
+ end
224
+
225
+ # Returns the string representation of the object
226
+ # @return [String] String presentation of the object
227
+ def to_s
228
+ to_hash.to_s
229
+ end
230
+
231
+ # to_body is an alias to to_hash (backward compatibility)
232
+ # @return [Hash] Returns the object in the form of hash
233
+ def to_body
234
+ to_hash
235
+ end
236
+
237
+ # Returns the object in the form of hash
238
+ # @return [Hash] Returns the object in the form of hash
239
+ def to_hash
240
+ hash = {}
241
+ self.class.attribute_map.each_pair do |attr, param|
242
+ value = self.send(attr)
243
+ if value.nil?
244
+ is_nullable = self.class.openapi_nullable.include?(attr)
245
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
246
+ end
247
+
248
+ hash[param] = _to_hash(value)
249
+ end
250
+ hash
251
+ end
252
+
253
+ # Outputs non-array value in the form of hash
254
+ # For object, use to_hash. Otherwise, just return the value
255
+ # @param [Object] value Any valid value
256
+ # @return [Hash] Returns the value in the form of hash
257
+ def _to_hash(value)
258
+ if value.is_a?(Array)
259
+ value.compact.map { |v| _to_hash(v) }
260
+ elsif value.is_a?(Hash)
261
+ {}.tap do |hash|
262
+ value.each { |k, v| hash[k] = _to_hash(v) }
263
+ end
264
+ elsif value.respond_to? :to_hash
265
+ value.to_hash
266
+ else
267
+ value
268
+ end
269
+ end
270
+
271
+ end
272
+
273
+ end