Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #8651
Closed
Open
Issue created Feb 09, 2021 by Administrator@rootContributor4 of 6 checklist items completed4/6 checklist items

[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

Assignee
Assign to
Time tracking