Skip to content

Commit 08347b7

Browse files
Merge pull request #178 from Yona-Appletree/bug-172
Fix for #172 - Handling empty @JsonTypeName() correctly.
2 parents ad9fe25 + 1634211 commit 08347b7

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

typescript-generator-core/src/main/java/cz/habarta/typescript/generator/parser/Jackson2Parser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private String getDiscriminantPropertyName(JsonTypeInfo jsonTypeInfo) {
170170
private String getTypeName(final Class<?> cls) {
171171
// find @JsonTypeName recursively
172172
final JsonTypeName jsonTypeName = getAnnotationRecursive(cls, JsonTypeName.class);
173-
if (jsonTypeName != null) {
173+
if (jsonTypeName != null && ! jsonTypeName.value().isEmpty()) {
174174
return jsonTypeName.value();
175175
}
176176
// find @JsonSubTypes.Type recursively

typescript-generator-core/src/test/java/cz/habarta/typescript/generator/Jackson2ParserTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ private static interface ParentWithNameDiscriminant {
8989
@JsonTypeName("explicit-name1")
9090
private static class SubTypeDiscriminatedByName1 implements ParentWithNameDiscriminant {
9191
}
92+
@JsonTypeName(/* Default should be the simplename of the class */)
9293
private static class SubTypeDiscriminatedByName2 implements ParentWithNameDiscriminant {
9394
}
9495
private static class SubTypeDiscriminatedByName3 implements ParentWithNameDiscriminant {

0 commit comments

Comments
 (0)