OpenAPITools / OpenAPITools/openapi-generator
[BUG] [Python] Misplaced __init__.py in client code when period is specified in package name
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used?
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Bounty to sponsor the fix (example)
Description
a) Generating a python client with both --model-package and --api-package parameters containing a '.' creates the api and models init.py file in the wrong directory.
Options --model-package pkg.models and --api-package pkg.api generate the directories openapi_client/pkg.models and openapi_client/pkg.api, in addition to openapi_client/pkg/models and openapi_client/pkg/api.
b) The init.py for the api contains wrong import lines, while the "model" one is correct.
--- openapi_client/pkg.models/init.py:
import models into model package
from openapi_client.pkg.models.error import Error
from openapi_client.pkg.models.pet import Pet
--- openapi_client/pkg.api/init.py ("openapi_client." missing form package name):
import apis into api package
from pkg.api.pets_api import PetsApi
openapi-generator version
Confirmed with v4.0.0-beta3
OpenAPI declaration file content or url
Using standard petstore.json
Command line used for generation
openapi-generator generate -g python -i petstore.json -o output --model-package pkg.models --api-package pkg.api
Steps to reproduce
Run the command above on the standard petstore.json spec file
Related issues/PRs
a) PR #2508 fixes a similar issue in the server code.
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Run the provided openapi-generator command with petstore.json, --model-package pkg.models, and --api-package pkg.api, then inspect the generated openapi_client/pkg.models and openapi_client/pkg.api paths. Compare their init.py locations and import lines with the expected package structure, and review PR #2508 for the related server-side fix; done means no extra dotted-directory packages and correct imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100