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.
Uh oh!
There was an error while loading. Please reload this page.
-
The Jackson
@JsonTypeInfoannotation has a property calleddefaultImpl.From the
defaultImplJavadoc: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
defaultImpldescribes.Beta Was this translation helpful? Give feedback.
All reactions