Deserializes response into an object. :param response: RESTResponse object to be deserialized. :param response_type: For the response, a tuple containing: valid classes a list containing valid classes (for list schemas) a dict containing a tuple o
(self, response, response_type, _check_type)
| 313 | ) |
| 314 | |
| 315 | def deserialize(self, response, response_type, _check_type): |
| 316 | """Deserializes response into an object. |
| 317 | |
| 318 | :param response: RESTResponse object to be deserialized. |
| 319 | :param response_type: For the response, a tuple containing: |
| 320 | valid classes |
| 321 | a list containing valid classes (for list schemas) |
| 322 | a dict containing a tuple of valid classes as the value |
| 323 | Example values: |
| 324 | (str,) |
| 325 | (Pet,) |
| 326 | (float, none_type) |
| 327 | ([int, none_type],) |
| 328 | ({str: (bool, str, int, float, date, datetime, str, none_type)},) |
| 329 | :param _check_type: boolean, whether to check the types of the data |
| 330 | received from the server |
| 331 | :type _check_type: bool |
| 332 | |
| 333 | :return: deserialized object. |
| 334 | """ |
| 335 | # handle file downloading |
| 336 | # save response body into a tmp file and return the instance |
| 337 | if response_type == (file_type,): |
| 338 | content_disposition = response.getheader("Content-Disposition") |
| 339 | return deserialize_file( |
| 340 | response.data, |
| 341 | self.configuration, |
| 342 | content_disposition=content_disposition, |
| 343 | ) |
| 344 | |
| 345 | # fetch data from response object |
| 346 | try: |
| 347 | received_data = json.loads(response.data) |
| 348 | except ValueError: |
| 349 | received_data = response.data |
| 350 | |
| 351 | # store our data under the key of 'received_data' so users have some |
| 352 | # context if they are deserializing a string and the data type is wrong |
| 353 | deserialized_data = validate_and_convert_types( |
| 354 | received_data, |
| 355 | response_type, |
| 356 | ["received_data"], |
| 357 | True, |
| 358 | _check_type, |
| 359 | configuration=self.configuration, |
| 360 | ) |
| 361 | return deserialized_data |
| 362 | |
| 363 | def call_api( |
| 364 | self, |
no test coverage detected