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

Fix issue: Microprofile dateLibrary java8 not working #6062

Merged

Conversation

Ravisankar-Challa
Copy link
Contributor

This fixes the issue reported here #6028
setting dateLibrary to java8 is generating joda time library imports.

@@ -199,7 +199,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
public void processOpts() {
if ((WEBCLIENT.equals(getLibrary()) && "threetenbp".equals(dateLibrary)) || NATIVE.equals(getLibrary())) {
dateLibrary = "java8";
} else if (MICROPROFILE.equals(getLibrary())) {
} else if (MICROPROFILE.equals(getLibrary()) && "threetenbp".equals(dateLibrary)) {
Copy link
Member

Choose a reason for hiding this comment

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

Is it correct to say that MICROPROFILE only supports legacy datetime library?

If yes, what about throwing a warning using LOGGER.warn to inform the user on that.

Copy link
Contributor Author

@Ravisankar-Challa Ravisankar-Challa Apr 29, 2020

Choose a reason for hiding this comment

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

@wing328 The reported issue is setting dateLibrary=java8 or dateLibrary=native microprofile rest client is generating class files with Joda time because at line 424 it has been hard coded to org.joda.time.LocalDate.
So I removed line 424.

Next coming to line number 202 if the user doesn't provide any dateLibrary we need to default it to native which is java.util.Date for microprofile rest client.

If the user doesn't select dateLibrary open api defaults to threetenbp. So we are making a check at line 202 and forcing dateLibrary to be native if it is microprofile & threetenbp.

If user selects dateLibrary='java8' or 'joda' or 'native' the condition at line 202 will not pass and what ever dateLibrary defined by user is used.

I have tested following with the above changes.

  1. java -jar openapi-generator-cli.jar generate -i petstore.yaml -g java --library microprofile //generates java.util.Date because no dateLibrary is specified
  2. java -jar openapi-generator-cli.jar generate -i petstore.yaml -g java --library microprofile --additional-properties dateLibrary=java8
  3. java -jar openapi-generator-cli.jar generate -i petstore.yaml -g java --library microprofile --additional-properties dateLibrary=joda

Copy link
Member

Choose a reason for hiding this comment

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

Tested with these and the results are good.

@wing328 wing328 merged commit b729e1d into OpenAPITools:master Jun 17, 2020
@wing328 wing328 added this to the 5.0.0 milestone Jun 17, 2020
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.

2 participants