Fix issue: Microprofile dateLibrary java8 not working#6062
Conversation
| 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)) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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.
- java -jar openapi-generator-cli.jar generate -i petstore.yaml -g java --library microprofile //generates java.util.Date because no dateLibrary is specified
- java -jar openapi-generator-cli.jar generate -i petstore.yaml -g java --library microprofile --additional-properties dateLibrary=java8
- java -jar openapi-generator-cli.jar generate -i petstore.yaml -g java --library microprofile --additional-properties dateLibrary=joda
There was a problem hiding this comment.
Tested with these and the results are good.
This fixes the issue reported here #6028
setting dateLibrary to java8 is generating joda time library imports.