-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
[#19921] Add RFC 3339 compatible Jackson module for java.time types #19925
base: master
Are you sure you want to change the base?
[#19921] Add RFC 3339 compatible Jackson module for java.time types #19925
Conversation
a4f83f8
to
c0703e3
Compare
I'm pretty sure Java implementations can already deserialize RFC3339 datetimes... |
@@ -187,6 +187,7 @@ public class ApiClient { | |||
{{/joda}} | |||
objectMapper.registerModule(new JavaTimeModule()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The JavaTimeModule can already deserialize RFC3339 datetimes
I can tell you, it does not. The If you don't believe me, try it out for yourself: https://onecompiler.com/jshell/42vrgfpy8 |
As per its ABNF, RFC3339 doesn't support space as a separator. |
I integrated an application which uses this format, so clearly, there is precedent for this need. I doubt that application will change the representation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @beikov, thanks for the PR! Apart from the small topics I commented on separately, this PR looks good to me. I tested the changes locally and can confirm that the changes enable the parsing of additional timestamp formats.
@@ -187,6 +187,7 @@ public class ApiClient { | |||
{{/joda}} | |||
objectMapper.registerModule(new JavaTimeModule()); | |||
{{#openApiNullable}} | |||
objectMapper.registerModule(new RFC3339JavaTimeModule()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this new line shouldn't be inside the {{#openApiNullable}}
block, right?
Function<FromDecimalArguments, T> fromNanoseconds, | ||
BiFunction<T, ZoneId, T> adjust, | ||
boolean replaceZeroOffsetAsZ) { | ||
super( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This super constructor is deprecated (see here). Could you please switch to a different one? I guess you could simply use the one recommended in the above link. And for the additional parameters required there, you could use the default values. (DEFAULT_NORMALIZE_ZONE_ID=true, DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS=false)
@@ -678,6 +678,8 @@ public void processOpts() { | |||
additionalProperties.remove(SERIALIZATION_LIBRARY_GSON); | |||
additionalProperties.remove(SERIALIZATION_LIBRARY_JSONB); | |||
supportingFiles.add(new SupportingFile("RFC3339DateFormat.mustache", invokerFolder, "RFC3339DateFormat.java")); | |||
supportingFiles.add(new SupportingFile("RFC3339InstantDeserializer.mustache", invokerFolder, "RFC3339InstantDeserializer.java")); | |||
supportingFiles.add(new SupportingFile("RFC3339JavaTimeModule.mustache", invokerFolder, "RFC3339JavaTimeModule.java")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional, not required for PR approval imo: Currently these supporting files are added even if the chosen library doesn't use them at all. You could introduce an additional if
here to only add the files where they are actually supported.
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.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08)