Skip to content

[BUG][Python] Composed Model serialization bug (anyOf) #10719

@gbvanrenswoude

Description

@gbvanrenswoude

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

When generating a client from an OAS with a composed model situation (like https://gist.github.com/gbvanrenswoude/1143a79dd6f150931c5c00826f6454a2) the resulting EventModel class does contain wrong information about the possible Models being used:

openapi_client/model/event_model.py

    def openapi_types():
        """
        This must be a method because a model may have properties that are
        of type self, this must run after the class is loaded

        Returns
            openapi_types (dict): The key is attribute name
                and the value is attribute type.
        """
        return {
            'event_payload': (bool, date, datetime, dict, float, int, list, str, none_type,),  # noqa: E501
            'correlatie_id': (str,),  # noqa: E501
            'event_title': (str,),  # noqa: E501
        }

Where

'event_payload': (bool, date, datetime, dict, float, int, list, str, none_type,),  # noqa: E501

is wrong. This might indicate a composed model serialization bug caused by the use of anyOf in the OAS.

replicate

In order to replicate the situation, save the linked gist as whoof.json.
The command then used is openapi-generator generate -i whoof.json -g python -o resources/whoof_api_client

openapi-generator version

5.3.0

With 5.2.0 the issue exists too, but results in 'event_payload': (dict,), # noqa: E501.

related issues

This might be related to this PR:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions