Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][Python] model_to_dict fails when x is a dictionary in model_utils.py #8651

Closed
4 of 6 tasks
code-lucidal58 opened this issue Feb 9, 2021 · 1 comment
Closed
4 of 6 tasks

Comments

@code-lucidal58
Copy link
Contributor

code-lucidal58 commented Feb 9, 2021

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.
#8387

@code-lucidal58
Copy link
Contributor Author

I think this issue is fixed with this merge #9153. Hence closing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants