@@ -3,6 +3,7 @@ package com.github.swagger.enumeratum.converter
33import io .swagger .v3 .core .converter ._
44import io .swagger .v3 .oas .models .media ._
55import models .{
6+ Animal ,
67 Ctx ,
78 ModelWCtxEnum ,
89 ModelWCtxEnumAndAnnotation ,
@@ -76,7 +77,7 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue
7677
7778 val field = model.value.getProperties.get(" field" )
7879 field shouldBe a[StringSchema ]
79- field.asInstanceOf [StringSchema ].getRequired shouldBe Seq .empty
80+ field.asInstanceOf [StringSchema ].getRequired shouldBe null
8081
8182 val schema = field.asInstanceOf [StringSchema ]
8283 schema.getDescription shouldEqual (null )
@@ -85,6 +86,26 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue
8586 nullSafeList(model.value.getRequired) shouldBe Seq (" field" )
8687 }
8788
89+ it should " process sealed abstract class" in {
90+ val converter = ModelConverters .getInstance()
91+ val schemas = converter.readAll(classOf [Animal ]).asScala.toMap
92+ val catModel = findModel(schemas, " Cat" )
93+ catModel should be(defined)
94+ val catProps = catModel.value.getProperties
95+ catProps should have size 3
96+ catProps.get(" name" ) shouldBe a[StringSchema ]
97+ catProps.get(" age" ) shouldBe a[IntegerSchema ]
98+ catProps.get(" animalType" ) shouldBe a[StringSchema ]
99+ catModel.value.getRequired.asScala shouldEqual Seq (" age" , " animalType" , " name" )
100+ val dogModel = findModel(schemas, " Dog" )
101+ dogModel should be(defined)
102+ val dogProps = dogModel.value.getProperties
103+ dogProps should have size 2
104+ dogProps.get(" name" ) shouldBe a[StringSchema ]
105+ dogProps.get(" animalType" ) shouldBe a[StringSchema ]
106+ dogModel.value.getRequired.asScala shouldEqual Seq (" animalType" , " name" )
107+ }
108+
88109 it should " not add additional model when enum field is annotated" in {
89110 val converter = ModelConverters .getInstance()
90111 val schemas = converter.readAll(classOf [ModelWCtxEnumAndAnnotation ]).asScala.toMap
0 commit comments