Forum Discussion

guyou's avatar
guyou
New Contributor
5 years ago

Response composition in Python is missing some import

Hi,

 

When using message composition, the Python generated code is missing some import.

 

The specification contains:

 

components:
  schemas:
    simple_response:
      title: simple response
      type: object
      required:
      - return
      properties:
        return:
          type: integer
          description: indicateur de succès de l'opération
          enum:
            - 0
            - 1
    error_response:
      title: error message
      allOf:
      - $ref: '#/components/schemas/simple_response'
      - type: object
        required:
        - msg
        properties:
          msg:
            type: string
            description: le message d'erreur

The generated code produces the following error:

Traceback (most recent call last):
  File "./test-python.py", line 3, in <module>
    import pyopenkarotz
  File "/home/user/Devel/openkarotz-openapi/python/pyopenkarotz/__init__.py", line 18, in <module>
    from pyopenkarotz.api.default_api import DefaultApi
  File "/home/user/Devel/openkarotz-openapi/python/pyopenkarotz/api/__init__.py", line 6, in <module>
    from pyopenkarotz.api.default_api import DefaultApi
  File "/home/user/Devel/openkarotz-openapi/python/pyopenkarotz/api/default_api.py", line 20, in <module>
    from pyopenkarotz.api_client import ApiClient
  File "/home/user/Devel/openkarotz-openapi/python/pyopenkarotz/api_client.py", line 26, in <module>
    import pyopenkarotz.models
  File "/home/user/Devel/openkarotz-openapi/python/pyopenkarotz/models/__init__.py", line 24, in <module>
    from pyopenkarotz.models.error_response import ErrorResponse
  File "/home/user/Devel/openkarotz-openapi/python/pyopenkarotz/models/error_response.py", line 19, in <module>
    class ErrorResponse(object):
  File "/home/user/Devel/openkarotz-openapi/python/pyopenkarotz/models/error_response.py", line 35, in ErrorResponse
    if hasattr(SimpleResponse, "swagger_types"):
NameError: name 'SimpleResponse' is not defined

The generated code is missing the import of the SimpleResponse in ErrorResponse related file.

 

Am I missing something?

 

Codegen version is 3.0.20.