Only check in lists and dictionaries

The "in" operator also works on strings which can cause problems with this line if the attribute and the object are named the same thing.

Signed-off-by: George Sibble <gsibble@gmail.com>
This commit is contained in:
George Sibble 2013-07-16 14:20:49 -07:00
parent 3cbf2abc5c
commit 4d05b5d81f

View File

@ -159,7 +159,7 @@ class ApiClient:
instance = objClass()
for attr, attrType in instance.swaggerTypes.iteritems():
if attr in obj:
if attr in obj and type(obj) in [list, dict]:
value = obj[attr]
if attrType in ['str', 'int', 'long', 'float', 'bool']:
attrType = eval(attrType)