cancel
Showing results for 
Search instead for 
Did you mean: 

Response composition in Python is missing some import

SOLVED
New Contributor

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Hi @guyou,

This is a bug. Please open an issue in the Swagger Codegen repository on GitHub:

https://github.com/swagger-api/swagger-codegen/issues


Helen Kosova
SmartBear Documentation Team Lead
________________________
Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

2 REPLIES 2
Highlighted
Moderator

Hi @guyou,

This is a bug. Please open an issue in the Swagger Codegen repository on GitHub:

https://github.com/swagger-api/swagger-codegen/issues


Helen Kosova
SmartBear Documentation Team Lead
________________________
Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today

View solution in original post

Highlighted
New Contributor

New Here?
Join us and watch the welcome video:
Announcements