Skip to content

Commit c8f2760

Browse files
authored
Merge pull request #138 from samson0v/master
Fixed model finding if model has dyn fields
2 parents 026ca52 + 01c930f commit c8f2760

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

tb_rest_client/api_client.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -334,10 +334,16 @@ def __deserialize(self, data, klass):
334334
klass = found_class
335335

336336
except AttributeError:
337-
found_class = getattr(tb_rest_client.models.models_ce, klass)
338-
# if all(attr in list(found_class.attribute_map.values()) for attr in list(data.keys())):
339-
# if sorted(list(found_class.attribute_map.values())) == sorted(list(data.keys())):
340-
klass = found_class
337+
try:
338+
found_class = getattr(tb_rest_client.models.models_ce, klass)
339+
# if all(attr in list(found_class.attribute_map.values()) for attr in list(data.keys())):
340+
# if sorted(list(found_class.attribute_map.values())) == sorted(list(data.keys())):
341+
klass = found_class
342+
except AttributeError:
343+
print('WARNING: received data fields not the same as in the {0} model (dyn fields problem)'.format(
344+
klass))
345+
found_class = getattr(tb_rest_client.models.models_pe, klass)
346+
klass = found_class
341347
# else:
342348
# return self.__deserialize(data, type(data))
343349
return self.__deserialize_data(data, klass)

0 commit comments

Comments
 (0)