-
Notifications
You must be signed in to change notification settings - Fork 89
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
Support java.time.Duration and java.time.Period with examples and tests #369
Support java.time.Duration and java.time.Period with examples and tests #369
Conversation
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.
LGTM. @MikeEdgar, @EricWittmann w.d.y.t ?
I like this, but my thoughts are that we should use standard-based naming rather than Java-based. For example, a Java In any case, I think it should be clear to the API consumer that |
I'm referring to the "Durations" and "Period" section in Appendix A of RFC 3339. |
@MikeEdgar according to javadoc https://docs.oracle.com/javase/8/docs/api/java/time/Period.html
So yes they're the same format, but one supports Do you think it'll be better to have only one constant here? In that case I think we can't provide two different examples though... Let me know how I can change this. |
Yes, my thought is that they should both be |
@MikeEdgar I pushed another commit, now we use always duration, there's a link of both the Javadoc and the RFC, and an example that is parsed from both classes. I think this might be ok for now, as it's still better than the current implementation that prints the internals of the |
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.
LGTM. @MikeEdgar ?
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.
Looks good - thank you @lucamolteni
Currently
java.time.Period
andjava.time.Duration
fields are shown in this wayNeedless to say, this is not the correct way to provide a Duration or a Period in a REST endpoint.
This patches supports these two datatypes with this output
I read this shouldn't be the "canonical" way to support custom formats and that they're discussing the way to do in the specification, but as smallrye-open-api supports most of
java.time
classes I think it'd make sense to support all of them.