openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

from_openapi_data() missing 1 required positional argument

Open jsciame opened this issue 2 years ago • 0 comments

Description

Error using generated models.

vidispine_client.exceptions.ApiValueError: Invalid inputs given to generate an instance of 'MediaComponentType'. The input data was invalid for the allOf schema 'MediaComponentType' in the composed schema 'AudioComponentType'. Error=Invalid inputs given to generate an instance of 'MediaComponentTypeAllOf'. The input data was invalid for the allOf schema 'MediaComponentTypeAllOf' in the composed schema 'MediaComponentType'. Error=_from_openapi_data() missing 1 required positional argument: 'time_base'

openapi-generator version

Snapshot: openapi-generator-cli-7.0.0-20220719.043604-2.jar

OpenAPI declaration file content or url
  MediaComponentType:
      allOf:
      - $ref: '#/components/schemas/ComponentType'
      - type: object
        properties:
          numberOfPackets:
            type: integer
            format: int64
          profile:
            type: integer
            format: int32
          itemTrack:
            type: string
          timeBase:
            $ref: '#/components/schemas/TimeBaseType'
          level:
            type: integer
            format: int32
          repeatCount:
            type: integer
            format: int64
          startTimestamp:
            $ref: '#/components/schemas/TimeCodeType'
          interval:
            $ref: '#/components/schemas/TimeIntervalType'
          pid:
            type: integer
            format: int32
          edl:
            $ref: '#/components/schemas/EDLType'
          codec:
            type: string
          extradata:
            type: string
          segment:
            type: integer
            format: int32
          duration:
            $ref: '#/components/schemas/TimeCodeType'
          trackOrder:
            type: integer
            format: int32
          essenceStreamId:
            type: integer
          bitrate:
            type: integer
   AudioComponentType:
      allOf:
      - $ref: '#/components/schemas/MediaComponentType'
      - required:
        - channelCount
        type: object
        properties:
          channelCount:
            type: integer
          frameSize:
            type: integer
          channelLayout:
            type: integer
            format: int64
          sampleFormat:
            type: string
          mediaInfo:
            $ref: '#/components/schemas/AudioMediaInfoType'
          blockAlign:
            type: integer
Command line used for generation

java -jar openapi-generator-cli-7.0.0-20220719.043604-2.jar generate -i openapi/spec.yaml -g python-experimental --package-name vidispine_client

Also tried the regular python generator.

Steps to reproduce
  1. Generate the code using the cli
  2. install the generated package pip install ../vidispine-openapi/
  3. Attempt to use a model class and feed it a dictionary as parameters
    def test_model(self):
        component = {
            "channelCount": 2,
            "channelLayout": 3,
            "sampleFormat": "AV_SAMPLE_FMT_FLTP",
            "frameSize": 1024,
            "mediaInfo": {},
            "id": "VX-334",
            "codec": "aac",
            "timeBase": {
                "numerator": 1,
                "denominator": 48000
            },
            "itemTrack": "A1",
            "essenceStreamId": 1,
            "bitrate": 192000,
            "numberOfPackets": 130126,
            "extradata": "1190",
            "pid": 2,
            "duration": {
                "samples": 133249472,
                "timeBase": {
                    "numerator": 1,
                    "denominator": 48000
                }
            },
            "profile": 1,
            "edl": {
                "timeScale": {
                    "numerator": 1,
                    "denominator": 48000
                },
                "entry": [
                    {
                        "start": 448,
                        "length": 133249472,
                        "mediaRate": 65536
                    }
                ]
            },
            "startTimestamp": {
                "samples": 0,
                "timeBase": {
                    "numerator": 1,
                    "denominator": 48000
                }
            }
        }
        vidispine_client.models.AudioComponentType(
            **helpers.to_snake_case(component))

Get the following error

Traceback (most recent call last):
  File "/Users/jsciame/PythonProjects/vidispine/test/unit/test_shape.py", line 97, in test_model
    vidispine_client.models.AudioComponentType(
  File "/Users/jsciame/PythonProjects/vidispine/venv/lib/python3.9/site-packages/vidispine_client/model_utils.py", line 49, in wrapped_init
    return fn(_self, *args, **kwargs)
  File "/Users/jsciame/PythonProjects/vidispine/venv/lib/python3.9/site-packages/vidispine_client/model/audio_component_type.py", line 404, in __init__
    composed_info = validate_get_composed_info(
  File "/Users/jsciame/PythonProjects/vidispine/venv/lib/python3.9/site-packages/vidispine_client/model_utils.py", line 2012, in validate_get_composed_info
    allof_instances = get_allof_instances(self, model_args, constant_args)
  File "/Users/jsciame/PythonProjects/vidispine/venv/lib/python3.9/site-packages/vidispine_client/model_utils.py", line 1807, in get_allof_instances
    raise ApiValueError(
vidispine_client.exceptions.ApiValueError: Invalid inputs given to generate an instance of 'MediaComponentType'. The input data was invalid for the allOf schema 'MediaComponentType' in the composed schema 'AudioComponentType'. Error=Invalid inputs given to generate an instance of 'MediaComponentTypeAllOf'. The input data was invalid for the allOf schema 'MediaComponentTypeAllOf' in the composed schema 'MediaComponentType'. Error=_from_openapi_data() missing 1 required positional argument: 'time_base'
Related issues/PRs
Suggest a fix/enhancement

jsciame avatar Aug 09 '22 16:08 jsciame