[BUG] Python generator with "--api-package" does not create "__init__.py" files in generated directories
🐛 Bug Report:
Describe the bug
When using openapi-generator-cli version 7.9.0 to generate Python client code with the --api-package option, the generator does not create an __init__.py file in the specified package directory. This causes the generated sub-packages to not be recognized as Python modules, leading to issues during package installation and usage.
Specifically, the command used:
openapi-generator-cli generate -i /input/openapi.yaml -g python --api-package org.my.test.api -o /output --package-name openapi_client
creates the correct directory structure (openapi_client/org/my/test/api/), but none of the directories (org, my,test, api) contain the necessary __init__.py file.
Steps to Reproduce
Steps to reproduce the behavior:
- Use
openapi-generator-cliversion 7.9.0 to generate Python code with the following command:
openapi-generator-cli generate -i /input/openapi.yaml -g python --api-package org.my.test.api -o /output --package-name openapi_client
- Navigate to the output directory (
/output/openapi_client). - Check the directory structure
org/my/test/api/ - Observe that the
__init__.pyfile is missing in all of these directories
Expected behavior
Each directory generated under --api-package should contain an __init__.py file, so that it is recognized as a Python package. This would allow seamless usage and installation of the generated client without requiring manual intervention to add these files.
Operation System (please complete the following information):
- I'm working with docker version:
openapitools/openapi-generator-cli:v7.9.0
Package System (please complete the following information):
- openapi-generator-cli Version: 7.9.0
Additional context
The lack of __init__.py files in the generated package structure requires manual intervention, which is cumbersome and makes the automated generation process incomplete. It would be helpful if the generator automatically created these files to ensure all directories are treated as Python packages. This issue impacts the usability of generated clients, especially when --api-package is used to specify custom package paths.
Please let me know if you need more information or have any suggestions for resolving this issue.
With --api-package option, another problem is:
- https://github.com/OpenAPITools/openapi-generator/issues/3285
if i remember correctly, apiPackage (global not generator) option is not supported in the python cilent generator