openapi-python-client icon indicating copy to clipboard operation
openapi-python-client copied to clipboard

Namespace based client package generate

Open abhinavsingh opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe. Currently, default client directory and package names are picked up from the schema files. E.g. For schema titled "Company API", we get a directory named company-api-client with package name being company_api_client.

Describe the solution you'd like We follow a namespace based solution throughout our company code base i.e. instead of from company_api_client import Client, we would like to have from company.api.client import Client. By doing so, generated package folder will also be compliant with our company GHA workflows and get automatically published to private pypi.

It's mostly a matter of creating those directories within directories without any __init__.py so that they get recognized as namespace. Some changes to the pyproject.toml and poetry config may also be needed. While I am able to override pyproject.toml templates, I am unable to find a way to customize the directory structure.

Is there a possibility to restructure the generated directories as explained above without forking/changing the core.

Best

abhinavsingh avatar Jun 04 '22 06:06 abhinavsingh

Example, if https://github.com/openapi-generators/openapi-python-client#project_name_override-and-package_name_override can also accept a dot separated package name to generate a namespace package

e.g. package_name_override=company.api.client will result in following directory structure:

  • company-api-client
    • company
      • api
        • client
          • init.py
          • ... other generated package files ...
    • pyproject.toml
    • ... other generated meta files ...

abhinavsingh avatar Jun 04 '22 07:06 abhinavsingh