[Java][okhttp-gson][retrofit2] Avoid ambiguous references for date and time classes (#18416) - #20230
Conversation
|
thanks for the PR I did a test with the command you provided but still got errors: Does it work for you locally in your environment? |
|
cc |
|
I got those same compilation errors locally also, but I got them in both
cases, when building from master and when building from the PR branch.
Since I haven't used any of the Petstore YAML specs before it wasn't clear
whether this was something that could be resolved with one of the
configuration properties or not (the PropertyNameCollision model class
looks odd and not like something that I would expect in a spec). It seemed
most relevant to this issue that the difference between the two builds was
the compile errors that went away.
…On Wed, Dec 4, 2024 at 12:09 AM William Cheng ***@***.***> wrote:
thanks for the PR
I did a test with the command you provided but still got errors:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project openapi-java-client: Compilation failure: Compilation failure:
[ERROR] C:\Users\wing3\tmp\openapi-generator-master\src\main\java\org\openapitools\client\model\PropertyNameCollision.java:[58,29] error: variable SERIALIZED_NAME_TYPE is already defined in class PropertyNameCollision
[ERROR] C:\Users\wing3\tmp\openapi-generator-master\src\main\java\org\openapitools\client\model\PropertyNameCollision.java:[61,17] error: variable type is already defined in class PropertyNameCollision
[ERROR] C:\Users\wing3\tmp\openapi-generator-master\src\main\java\org\openapitools\client\model\PropertyNameCollision.java:[63,29] error: variable SERIALIZED_NAME_TYPE is already defined in class PropertyNameCollision
[ERROR] C:\Users\wing3\tmp\openapi-generator-master\src\main\java\org\openapitools\client\model\PropertyNameCollision.java:[66,17] error: variable type is already defined in class PropertyNameCollision
[ERROR] C:\Users\wing3\tmp\openapi-generator-master\src\main\java\org\openapitools\client\model\PropertyNameCollision.java:[90,31] error: method type(String) is already defined in class PropertyNameCollision
[ERROR] C:\Users\wing3\tmp\openapi-generator-master\src\main\java\org\openapitools\client\model\PropertyNameCollision.java:[100,16] error: method getType() is already defined in class PropertyNameCollision
[ERROR] C:\Users\wing3\tmp\openapi-generator-master\src\main\java\org\openapitools\client\model\PropertyNameCollision.java:[104,14] error: method setType(String) is already defined in class PropertyNameCollision
[ERROR] C:\Users\wing3\tmp\openapi-generator-master\src\main\java\org\openapitools\client\model\PropertyNameCollision.java:[109,31] error: method type(String) is already defined in class PropertyNameCollision
[ERROR] C:\Users\wing3\tmp\openapi-generator-master\src\main\java\org\openapitools\client\model\PropertyNameCollision.java:[119,16] error: method getType() is already defined in class PropertyNameCollision
[ERROR] C:\Users\wing3\tmp\openapi-generator-master\src\main\java\org\openapitools\client\model\PropertyNameCollision.java:[123,14] error: method setType(String) is already defined in class PropertyNameCollision
Does it work for you locally in your environment?
—
Reply to this email directly, view it on GitHub
<#20230 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABCUU5KBD4W7GF6DR3JUVT2D2MC3AVCNFSM6AAAAABS63IRY2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMJWGI4DKMZVGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
can you please share the spec you used to reproduce the issue and confirmed the fix? |
|
I had chosen one of the Petstore YAML files from the project without looking too closely; when I went back and looked for one that appeared like it was for more general testing use, I found modules/openapi-generator/src/test/resources/3_0/petstore.yaml. When I used that in the commands above then I got a clean compile of the generated Java code with the fix branch, and I got compilation errors of the generated Java code with the master branch. Sorry for the confusion on my first attempt. Here is what I now can run from the master branch to show the original error: And here is what I can run from the PR branch to confirm the fix: Is that what you need? |
|
Did another round of tests and the result looks good. Likely I didn't test it correctly when I first reviewed the change. Thanks again for your contribution. |
This change adds some missing guards in Mustache templates to avoid having imports of conflicting date/time classes when using the Joda library. These guards were on the methods that used the differing date/time classes, but were not on the corresponding imports. Of the various Java library templates, only those for okhttp-gson and retrofit2 had these date/time class import patterns. It looks like these guards were once there but got accidentally removed as part of #11547.
I used the following command line to reproduce the issue on master using the Petstore API spec:
When I ran the same commands against the PR branch, the ambiguous class reference issues went away.
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)