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
  • #1663
Closed
Open
Issue created Dec 11, 2018 by Administrator@rootContributor

[BUG][Python] oneOf (with multi-level inheritance) misses code generation

Created by: tomghyselinck

Description

As a workaround for #1662 (closed) I was trying to use oneOf, listing the first-level inheritance objects instead of the base type.

Unfortunately, this shows pops up another related issue:

The generated code wants to resolve an OneOfDog object, but it looks like it is not generated anywhere.

Please note that you can also see that the member fields of the Pet and Dog parent object are missing in the AngryDog (cfr. #453 (closed)).

openapi-generator version

I used OpenAPI generator CLI version 4.0.0-SNAPSHOT: https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/openapi-generator-cli-4.0.0-20181210.103357-85.jar

OpenAPI declaration file content or url

See oneOf-multi-level-inheritance.yaml in the attached zip-file: oneOf-multi-level-inheritance.zip

Command line used for generation
java -jar openapi-generator-cli-4.x.jar generate -i ./oneOf-multi-level-inheritance.yaml -g python -o ./oneOf-multi-level-inheritance/client/python
Steps to reproduce
  1. Generate client code

    See also oneOf-multi-level-inheritance.sh.

    wget \
        'https://oss.sonatype.org/content/repositories/snapshots/org/openapitools/openapi-generator-cli/4.0.0-SNAPSHOT/openapi-generator-cli-4.0.0-20181210.103357-85.jar' \
        -O 'openapi-generator-cli-4.x.jar'
    rm -rf ./oneOf-multi-level-inheritance/
    java -jar openapi-generator-cli-4.x.jar generate -i ./oneOf-multi-level-inheritance.yaml -g python -o ./oneOf-multi-level-inheritance/client/python
  2. Start (mocked) server

    python3 -m connexion run --mock=all oneOf-multi-level-inheritance.yaml

  3. Run the client test

    (cd multi-level-inheritance/client/python/ && python3)

    import openapi_client
    api = openapi_client.DefaultApi()
    dog = api.dog_get()
    print(type(dog))
    print(dog)
    pet = api.pet_get()
    print(type(pet))
    print(pet)

    Output:

    <class 'openapi_client.models.angry_dog.AngryDog'>
    {'byting': True}
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/tom/programming/XRA-31/components/software/1.x-sc_qam/xra31api-rest/issues/oneOf-multi-level-inheritance/client/python/openapi_client/api/default_api.py", line 138, in pet_get
        (data) = self.pet_get_with_http_info(**kwargs)  # noqa: E501
      File "/home/tom/programming/XRA-31/components/software/1.x-sc_qam/xra31api-rest/issues/oneOf-multi-level-inheritance/client/python/openapi_client/api/default_api.py", line 205, in pet_get_with_http_info
        collection_formats=collection_formats)
      File "/home/tom/programming/XRA-31/components/software/1.x-sc_qam/xra31api-rest/issues/oneOf-multi-level-inheritance/client/python/openapi_client/api_client.py", line 335, in call_api
     _preload_content, _request_timeout)
      File "/home/tom/programming/XRA-31/components/software/1.x-sc_qam/xra31api-rest/issues/oneOf-multi-level-inheritance/client/python/openapi_client/api_client.py", line 174, in __call_api
        return_data = self.deserialize(response_data, response_type)
      File "/home/tom/programming/XRA-31/components/software/1.x-sc_qam/xra31api-rest/issues/oneOf-multi-level-inheritance/client/python/openapi_client/api_client.py", line 246, in deserialize
        return self.__deserialize(data, response_type)
      File "/home/tom/programming/XRA-31/components/software/1.x-sc_qam/xra31api-rest/issues/oneOf-multi-level-inheritance/client/python/openapi_client/api_client.py", line 274, in __deserialize
     klass = getattr(openapi_client.models, klass)
    AttributeError: module 'openapi_client.models' has no attribute 'OneOfDog'
Related issues/PRs
  • #1662 (closed)
  • #453 (closed)
Suggest a fix

I have no clue here (yet)

Assignee
Assign to
Time tracking