[python] Fixes a breakage while deserializing the read-only attributes (#10155)

* fixes a breakage while deserializing the read-only attributes

* updating generated samples

* taking care of the PR comments

* updating samples

* protect against cases where _spec_property_naming may not be present

* updating samples

* adding tests for this issue

* other generated files

* taking care of the comments

* updating the generated samples

Co-authored-by: Aanisha Mishra <aanisha.mishra05@gmail.com>
This commit is contained in:
Vikrant Balyan
2021-08-19 00:31:58 +05:30
committed by GitHub
parent a7de7095a7
commit 245aec14eb
16 changed files with 176 additions and 24 deletions

View File

@@ -1747,7 +1747,10 @@ def get_allof_instances(self, model_args, constant_args):
for allof_class in self._composed_schemas['allOf']:
try:
allof_instance = allof_class(**model_args, **constant_args)
if constant_args.get('_spec_property_naming'):
allof_instance = allof_class._from_openapi_data(**model_args, **constant_args)
else:
allof_instance = allof_class(**model_args, **constant_args)
composed_instances.append(allof_instance)
except Exception as ex:
raise ApiValueError(
@@ -1809,10 +1812,16 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None):
try:
if not single_value_input:
oneof_instance = oneof_class(**model_kwargs, **constant_kwargs)
if constant_kwargs.get('_spec_property_naming'):
oneof_instance = oneof_class._from_openapi_data(**model_kwargs, **constant_kwargs)
else:
oneof_instance = oneof_class(**model_kwargs, **constant_kwargs)
else:
if issubclass(oneof_class, ModelSimple):
oneof_instance = oneof_class(model_arg, **constant_kwargs)
if constant_kwargs.get('_spec_property_naming'):
oneof_instance = oneof_class._from_openapi_data(model_arg, **constant_kwargs)
else:
oneof_instance = oneof_class(model_arg, **constant_kwargs)
elif oneof_class in PRIMITIVE_TYPES:
oneof_instance = validate_and_convert_types(
model_arg,
@@ -1867,7 +1876,10 @@ def get_anyof_instances(self, model_args, constant_args):
continue
try:
anyof_instance = anyof_class(**model_args, **constant_args)
if constant_args.get('_spec_property_naming'):
anyof_instance = anyof_class._from_openapi_data(**model_args, **constant_args)
else:
anyof_instance = anyof_class(**model_args, **constant_args)
anyof_instances.append(anyof_instance)
except Exception:
pass