Extending Jackson JsonTypeInfo support to consider defaultImpl #278
Replies: 3 comments
-
The suggestion sounds good, and I've created PR #279 for that now.
For the second part, one would have to list all known identifiers and negate them:
While possible, I'd refrain from supporting this second half for now, as it seems rather excessive. If included, that should probably be hidden behind a new Or what do you reckon @eleftherias? |
Beta Was this translation helpful? Give feedback.
-
Thanks @CarstenWickner! |
Beta Was this translation helpful? Give feedback.
-
The change has been released as v4.26.0. |
Beta Was this translation helpful? Give feedback.
-
The Jackson
@JsonTypeInfo
annotation has a property calleddefaultImpl
.From the
defaultImpl
Javadoc:Example usage:
I imagine this project could support
defaultImpl
, by marking the Jackson subtype discriminator as non-required for the class indefaultImpl
.In the example above, the generated schema would contain:
Notice that "type" is not required for Dog-2, but is still required for Cat-2 and Mouse-2.
This way if "type" is missing, it defaults to "Dog", which is what
defaultImpl
describes.Beta Was this translation helpful? Give feedback.
All reactions