openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG][Python] ModuleNotFoundError when packagename contains dots

Open saigiridhar21 opened this issue 7 years ago • 0 comments

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator (example)?
  • [x] What's the version of OpenAPI Generator used?
  • [x] Have you search for related issues/PRs?
  • [x] What's the actual output vs expected output?
  • [ ] [Optional] Bounty to sponsor the fix (example)
Description

If we have dots in the packagename (e.g., openapi.client), then required directory structure is getting created like openapi/client. Inside openapi/client/, we will have api and models directories. But, __init__.py files are missing from those sub directories(at openapi and client level). So, the users of this built package will face ModuleNotFoundError: No module named 'openapi' error.

openapi-generator version

4.0.0

OpenAPI declaration file content or url
Command line used for generation

java -jar openapi-generator-cli.jar generate --generator-name python --input-spec openapi-schema.json --output openapi.client --additional-properties packagename=openapi.client

Steps to reproduce
  • Generate the SDK using a package name that contains dots e.g., openapi.client.
  • Then, build and install the SDK.
  • Try to import it in a separate project as a client/user of SDK and run some example code.
  • Then, an error will thrown like ModuleNotFoundError: No module named 'openapi'
Related issues/PRs
Suggest a fix

If the packagename contain dots, add __init__.py files at each sub directory level.

saigiridhar21 avatar May 24 '19 16:05 saigiridhar21