Describe the bug
It is possible to generate a model with a missing import leading to invalid python code.
The below to_multipart function is generated in the body for the create_upload_file_uploadfile__post model and references UploadConfig however it is not in scope.
Describe the bug It is possible to generate a model with a missing import leading to invalid python code.
The below
to_multipart
function is generated in the body for the create_upload_file_uploadfile__post model and referencesUploadConfig
however it is not in scope.The function
to_dict
right above it in the file lazily importsUploadConfig
OpenAPI Spec File
Desktop (please complete the following information):
Additional context I have been able to fix this locally by modifying the following
https://github.com/openapi-generators/openapi-python-client/blob/73f92ea7da8daa758bb237daa7cc26030cd32225/openapi_python_client/templates/model.py.jinja#L131-L134
Solution is to add the lazy import template that is found in
to_dict
https://github.com/openapi-generators/openapi-python-client/blob/73f92ea7da8daa758bb237daa7cc26030cd32225/openapi_python_client/templates/model.py.jinja#L126-L128