def __validate_inputs(self, kwargs): for param in self.params_map['enum']: if param in kwargs: check_allowed_values( self.allowed_values, (param,), kwargs[param] ) for param in self.params_map['validation']: if param in kwargs: check_validations( self.validations, (param,), kwargs[param] ) if kwargs['_check_input_type'] is False: return for key, value in six.iteritems(kwargs): fixed_val = validate_and_convert_types( value, self.openapi_types[key], [key], False, kwargs['_check_input_type'], configuration=self.api_client.configuration ) kwargs[key] = fixed_val
def deserialize(self, response, response_type, _check_type): """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 of valid classes as the value Example values: (str,) (Pet,) (float, none_type) ([int, none_type],) ({str: (bool, str, int, float, date, datetime, str, none_type)},) :param _check_type: boolean, whether to check the types of the data received from the server :return: deserialized object. """ # handle file downloading # save response body into a tmp file and return the instance if response_type == (file_type,): content_disposition = response.getheader("Content-Disposition") return deserialize_file( response.data, self.configuration, content_disposition=content_disposition, ) # fetch data from response object try: received_data = json.loads(response.data) except ValueError: received_data = response.data # store our data under the key of 'received_data' so users have some # context if they are deserializing a string and the data type is wrong deserialized_data = validate_and_convert_types( received_data, response_type, ["received_data"], True, _check_type, configuration=self.configuration, ) return deserialized_data