Skip to content

[BUG] [Python] Handling objects as dictionnaries not working in 6.2.1 #13997

@OmarBouslama

Description

@OmarBouslama

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

We have an Event model in OpenAPI that contains these fields:

    Event:
      type: object
      x-examples:
        example-1:
          name: watched_trailer
          occuredAt: '2013-07-16T19:20:30+1:00'
          properties: {}
      properties:
        name:
          type: string
        occuredAt:
          type: string
        properties:
          type: object
      required:
        - name
        - occuredAt

Using generator version 5.x.x, I was able to init the model this way in Python:
event = Event(name="xxx", occuredAt="2020-06-01", properties={"prop1": "value1"})

However, using the 6.2.1 version
we have this stack trace now

nothing has changed except using a new open API generator version

  File "/usr/local/lib/python3.10/site-packages/crm_client/model/update_customer_v1_request.py", line 318, in __new__
    return super().__new__(
  File "/usr/local/lib/python3.10/site-packages/crm_client/schemas.py", line 2990, in __new__
    return super().__new__(cls, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/crm_client/schemas.py", line 621, in __new__
    return __new_cls._get_new_instance_without_conversion_oapg(
  File "/usr/local/lib/python3.10/site-packages/crm_client/schemas.py", line 490, in _get_new_instance_without_conversion_oapg
    properties = cls._get_properties_oapg(arg, path_to_item, path_to_schemas)
  File "/usr/local/lib/python3.10/site-packages/crm_client/schemas.py", line 2133, in _get_properties_oapg
    new_value = property_cls._get_new_instance_without_conversion_oapg(
  File "/usr/local/lib/python3.10/site-packages/crm_client/schemas.py", line 493, in _get_new_instance_without_conversion_oapg
    items = cls._get_items_oapg(arg, path_to_item, path_to_schemas)
  File "/usr/local/lib/python3.10/site-packages/crm_client/schemas.py", line 1822, in _get_items_oapg
    new_value = item_cls._get_new_instance_without_conversion_oapg(
  File "/usr/local/lib/python3.10/site-packages/crm_client/schemas.py", line 490, in _get_new_instance_without_conversion_oapg
    properties = cls._get_properties_oapg(arg, path_to_item, path_to_schemas)
  File "/usr/local/lib/python3.10/site-packages/crm_client/schemas.py", line 2133, in _get_properties_oapg
    new_value = property_cls._get_new_instance_without_conversion_oapg(
  File "/usr/local/lib/python3.10/site-packages/crm_client/schemas.py", line 490, in _get_new_instance_without_conversion_oapg
    properties = cls._get_properties_oapg(arg, path_to_item, path_to_schemas)
  File "/usr/local/lib/python3.10/site-packages/crm_client/schemas.py", line 2133, in _get_properties_oapg
    new_value = property_cls._get_new_instance_without_conversion_oapg(
AttributeError: type object 'DynamicSchema' has no attribute '_get_new_instance_without_conversion_oapg'
openapi-generator version

6.2.1

OpenAPI declaration file content or url
Generation Details
Steps to reproduce

Add a model with that contains an object, generate the code and try to init the model by passing a dictionary to the object property
`AnyModel(some_field="value", object_property={"toto": "tata"})

Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions