Skip to content

Commit 88e4002

Browse files
committed
fix issue 804 - java discriminator
1 parent a7cdf59 commit 88e4002

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/v3/CodegenModel.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import io.swagger.v3.oas.models.media.Discriminator;
55

66
import java.util.ArrayList;
7-
import java.util.HashMap;
87
import java.util.List;
98
import java.util.Map;
109
import java.util.Objects;
@@ -518,11 +517,17 @@ public String getSubtypeName() {
518517
if (getInterfaceModels()!=null) {
519518
for (CodegenModel interfaceModel : getInterfaceModels()) {
520519
if (interfaceModel.getDiscriminator() != null && interfaceModel.getDiscriminator().getMapping() != null) {
521-
String name = interfaceModel.getDiscriminator().getMapping().get(classname);
522-
return name != null ? name : classname;
520+
String subTypeName = interfaceModel.getDiscriminator().getMapping().get(classname);
521+
if (subTypeName!=null) {
522+
return subTypeName;
523+
}
523524
}
524525
}
525526
}
526-
return classname;
527+
if (getParentModel()!=null && getParentModel().getDiscriminator()!=null && getParentModel().getDiscriminator().getMapping()!=null) {
528+
String subTypeName = getParentModel().getDiscriminator().getMapping().get(classname);
529+
return subTypeName!=null?subTypeName:name;
530+
}
531+
return name;
527532
}
528533
}

0 commit comments

Comments
 (0)