Wrong type Exception when changing the order of @JsonSubTypes annotation
See original GitHub issueThank you for the excellent library. Unfortunately I am having some trouble when using a more complex structure. Here is a minimal Example:
Given the following hierarchy:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(Line.class),
@JsonSubTypes.Type(Pt.class) })
public static class Loc {
}
@JsonSubTypes({
@JsonSubTypes.Type(Abs.class)
})
public static class Pt extends Loc {
}
public static class Abs extends Pt {
}
public static class Line extends Loc {
public List<Pt>attr;
}
the generator throws the exception Wrong type - working on [simple type, class com.example.Pt] - got [simple type, class com.example.Abs]
when calling ‘generator.generateJsonSchema(Loc.class);’
When changing the order of the subtype annotation on Loc
to
@JsonSubTypes({
@JsonSubTypes.Type(Pt.class),
@JsonSubTypes.Type(Line.class) })
everything works. Unfortunately in our POJOs we cannot modify all of subtype annotations to ensure that there is no backward dependency between them. Is this something that is easy to fix?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
java - De-serializing JSON to polymorphic object model using ...
Id.NAME, include=JsonTypeInfo.As.PROPERTY, property="type")" as annotation with your Interface. You can also define the order of properties when mapper ...
Read more >Deserialization of `@JsonTypeInfo` annotated type fails with ...
When attempting to deserialize to a concrete class that is part of a polymorphic type hierarchy, an InvalidTypeIdException is thrown if the ...
Read more >FasterXML/jackson-databind - Gitter
I've recently upgraded from Jackson 2.9.10 to 2.10.0 and notice a change in how Iterator ... VerifyError: Bad return type Exception Details: Location: ......
Read more >Jackson Exceptions - Problems and Solutions - Baeldung
The most common Jackson exceptions - the cause of the problem and the ... with a simple annotation — @JsonDeserialize on the abstract...
Read more >SUSE alert SUSE-SU-2022:1678-1 (jackson-databind ...
_appendSourceDesc()' + Add 'StreamWriteException' type to ... "currentValue" wrongly references to '@JsonTypeInfo' annotated object + DOM ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same issue.
Is my PR #109 not sufficient? I am sorry, I tried to mimic the style of the other tests, but I am not sure how it is supposed to work,