-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add 'formatTypeMapping' config option to allow overriding types used for formats #923
Add 'formatTypeMapping' config option to allow overriding types used for formats #923
Conversation
This commit introduces a new option `formatTypeMapping`, which maps from format (e.g. 'uri') to type (e.g. 'java.net.URI'). The current base types and configurations are left as-is. This means, that it is still possible to set 'useJodaDate' or 'dateType' as before. Alternatively, a mapping 'date' > 'org.joda.time.LocalDate' achieves the same output. With this change it is also possible to map non-standard formats to types. This logic is intentional, but not recommended to users as it invalidates the schema.
I'd actually go as far as to remove the options |
Thanks. Could you explain your use-case? |
Currently there are 14 formats defined by the spec. For each this library chose a suitable implementation in Java. Seeing the 2*3 options to configure dates ( A use case is Having said that my use case is still the edge case gh-910. Nonetheless, I imagine this solution is easier maintainable in the long run than the current 6 mutually exclusive date properties together with what might come in the future -- issues and json-schema drafts. |
I think you have made a strong case for this. I'll review the changes with the intention of including this in the next release. |
@@ -497,6 +497,12 @@ <h3>Parameters</h3> | |||
</td> | |||
<td align="center" valign="top">No (default <code>OS</code>)</td> | |||
</tr> | |||
<tr> | |||
<td valign="top">formatTypeMapping</td> | |||
<td valign="top">A mapping from format identifier (e.g. 'uri') to Java type (e.g. 'java.net.URI'). |
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.
Could you add an example to the description that shows what format the value should have?
@jrehwaldt It looks like you're finished on this PR. Okay for me to merge? Thanks again for your contributions. You've made changes very carefully and added tests where appropriate, which I really appreciate. |
Ready for merge, yes. Thank you. |
This commit introduces a new option
formatTypeMapping
, which maps from format(e.g. 'uri') to type (e.g. 'java.net.URI'). The current base types and configurations
are left as-is. This means, that it is still possible to set 'useJodaDate' or 'dateType'
as before. Alternatively, a mapping 'date' > 'org.joda.time.LocalDate' achieves the same
output.
With this change it is also possible to map non-standard formats to types. This logic is
intentional, but not recommended to users as it invalidates the schema.
This (partly) fixes gh-910 and is an alternative to gh-918.