You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Unable to deserialize model objects when using Python 3.7.
When running with Python 3.7 openapi_server.util._deserialize fails because typing.GenericMeta was removed from 3.7.
Describe the solution you'd like
I'm not sure on where we are at with support for 3.7, but I worked on this fix and figured I should pass it along for when we get ready to support 3.7. Other than this I haven't found other issues.
Describe alternatives you've considered
Python 3.6
def_deserialize(data, klass):
"""Deserializes dict, list, str into an object. :param data: dict, list or str. :param klass: class literal, or string of class name. :return: object. """fromcdst_places_app.openapi_server.models.base_model_importModelifdataisNone:
returnNoneifklassinsix.integer_typesorklassin (float, str, bool):
return_deserialize_primitive(data, klass)
elifklass==object:
return_deserialize_object(data)
elifklass==datetime.date:
returndeserialize_date(data)
elifklass==datetime.datetime:
returndeserialize_datetime(data)
eliftype(klass) ==typing.GenericMeta:
ifklass.__extra__==list:
return_deserialize_list(data, klass.__args__[0])
ifklass.__extra__==dict:
return_deserialize_dict(data, klass.__args__[1])
else:
returndeserialize_model(data, klass)
Python 3.7
importtyping_inspectdef_deserialize(data, klass):
"""Deserializes dict, list, str into an object. :param data: dict, list or str. :param klass: class literal, or string of class name. :return: object. """fromcdst_places_app.openapi_server.models.base_model_importModelifdataisNone:
returnNoneifklassinsix.integer_typesorklassin (float, str, bool):
return_deserialize_primitive(data, klass)
elifklass==object:
return_deserialize_object(data)
elifklass==datetime.date:
returndeserialize_date(data)
elifklass==datetime.datetime:
returndeserialize_datetime(data)
eliftyping_inspect.is_generic_type(klass):
iftyping_inspect.get_origin(klass) ==list:
return_deserialize_list(data, klass.__args__[0])
iftyping_inspect.get_origin(klass) ==dict:
return_deserialize_dict(data, klass.__args__[1])
else:
returndeserialize_model(data, klass)
I had the same problem with swagger-codegen and ended up migrating to openapi-codegen for unrelated reasons. My work around is on this issue swagger-api/swagger-codegen#8921, in case anyone is interested.
It does not depends on the typing_inspect, altough I am not sure that is relevant for every use case. However, my work around its not backwards compatible with python < 3.7.
Is your feature request related to a problem? Please describe.
Unable to deserialize model objects when using Python 3.7.
When running with Python 3.7 openapi_server.util._deserialize fails because typing.GenericMeta was removed from 3.7.
Describe the solution you'd like
I'm not sure on where we are at with support for 3.7, but I worked on this fix and figured I should pass it along for when we get ready to support 3.7. Other than this I haven't found other issues.
Describe alternatives you've considered
Python 3.6
Python 3.7
I'm not sure if the dict piece
works or not. I don't have a spec that triggers this code.
Additional context
The text was updated successfully, but these errors were encountered: