Skip to content
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] [bug] Fixed handling of dotted module names #2016

Merged
merged 1 commit into from
Feb 12, 2019
Merged

[python] [bug] Fixed handling of dotted module names #2016

merged 1 commit into from
Feb 12, 2019

Conversation

svenpanne
Copy link
Contributor

@svenpanne svenpanne commented Jan 29, 2019

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\. (Irrelevant point, Travis CI checked the PR in my fork.)
  • Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

Previously, if you used a packageName of the form foo.bar.baz, half of the
generated files of the python generator went into a subdirectory
foo/bar/baz (correct), the other half went into a subdirectory
foo.bar.baz (incorrect).

@taxpon @frol @mbohlool @cbornet @kenjones-cisco @tomplus @Jyhess

@svenpanne svenpanne changed the title Fixed handling of dotted module names in python generator. [python] [bug] Fixed handling of dotted module names Jan 29, 2019
@svenpanne
Copy link
Contributor Author

Corresponding fix for server part in #2041.

@@ -201,12 +201,14 @@ public void processOpts() {
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
additionalProperties.put(CodegenConstants.PACKAGE_VERSION, packageVersion);

// NOTE: The null case can happen during PythonClientOptionsTest.checkOptionsProcessing().
String packagePath = packageName == null ? "" : packageName.replace('.', File.separatorChar);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be cleaner to have packageName != null during the unit test PythonClientOptionsTest.checkOptionsProcessing ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that would be cleaner, but due to the slightly obscure mocking Kung Fu in the test I was unable to come up with something better.

I propose to land this change as it is (perhaps add a TODO), the current module name handling is totally unusable in non-trivial existing Python projects. Alternatively, somebody could give me a concrete hint how to fix the test... 😉

@rienafairefr
Copy link
Contributor

Tested on a real spec & project, works fine 👍

@wing328
Copy link
Member

wing328 commented Feb 8, 2019

@svenpanne thanks for the PR. What about using the packagePath() function approach in #2041 ?

Later we'll create a Python abstract class for Python client and server generators so keeping things a bit more consistent will make the refactoring easier.

Previously, if you used a packageName of the form "foo.bar.baz", half of the
generated files of the python generator went into a subdirectory
"foo/bar/baz" (correct), the other half went into a subdirectory
"foo.bar.baz" (incorrect).
@svenpanne
Copy link
Contributor Author

@svenpanne thanks for the PR. What about using the packagePath() function approach in #2041 ? [...]

Good idea, done. Note that I've fixed and improved the corresponding options test a bit, so the funny null check is gone. jmockit is a strange beast if you don't use it on a daily basis... 😕

@wing328 wing328 merged commit fd08478 into OpenAPITools:master Feb 12, 2019
@svenpanne svenpanne deleted the fix-dotted-module-names branch February 12, 2019 07:21
A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
…ols#2016)

Previously, if you used a packageName of the form "foo.bar.baz", half of the
generated files of the python generator went into a subdirectory
"foo/bar/baz" (correct), the other half went into a subdirectory
"foo.bar.baz" (incorrect).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants