[BUG][Python] model_to_dict fails when x is a dictionary in model_utils.py
Created by: code-lucidal58
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
if isinstance(value, list):
if not value or isinstance(value[0], PRIMITIVE_TYPES):
# empty list or primitive types
result[attr] = value
elif isinstance(value[0], ModelSimple):
result[attr] = [x.value for x in value]
else:
result[attr] = [model_to_dict(x, serialize=serialize) for x in value]
In the else
part, if x is a dictionary, meaning value
is a list of dictionaries, model_to_dict
fails. Because x is not a valid and model_to_dict
, assuming it to be a model, tries to access the _composed_schemas
.
openapi-generator version
master build and released v5.0.1
Suggest a fix
Check if x is a model by checking if it has the _data_store
property. This was the approach before the 5th Jan commit to this file.
https://github.com/OpenAPITools/openapi-generator/pull/8387