-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Python] Support for package hierarchy #1302
Comments
This sounds like a related, if not the same, issue. |
I'm upvoting this as helpful. When I ran the command line with a |
So I was able to work around this by customizing 3 of the python templates to use relative imports, as follows. __init__api.mustache
__init__model.mustache
__init__package.mustache
|
@mmunz-nextdoor thanks for sharing the workaround. Do you mind submitting a PR so that we can review the change more easily? |
Thanks @wing328 linking me to this discussion, this is very closed to my requirement. Let me share my user case:
A package hierarchy is required to support my case well. I have a PR be committed to swagger-codegen to solve this problem, it works well in my side. |
I have submitted a patch for the client part in #2016 and will look at the server part, soon. |
BTW: |
Fix for server part in #2041. |
Description
I am trying to generate a service client for a project that uses a particular package hierarchy by convention. I have tried the following but am yet to generate a client that I can successfully import, due to mis-matching/incorrect import statements, and files that are placed in the wrong folders.
For example #1 (below) I get code like
import api
whereimport foo.bar.baz.api
is desired. With example #2, I get directories likefoo.bar.baz.my_client.model
whenfoo/bar/baz/my_client/model
is desired.ex.1)
ex.2)
my_config.json:
openapi-generator version
3.3.1
OpenAPI declaration file content or url
I don't believe this is relevant. If needed I can provide a version of the spec.
Command line used for generation
See above.
Steps to reproduce
Run either of the commands above.
Related issues/PRs
I didn't find any.
Suggest a fix/enhancement
It seems like there is some code that is parsing the "foo.bar.baz" syntax into a file path since some of the files are correctly placed with the right import statements. Presumably some of the generator code (the part that handles
--api-package api --model-package model
) is not correctly handling these package names.Thanks for reviewing this. Any pointers/suggestions would be really appreciated!
The text was updated successfully, but these errors were encountered: