@@ -2,7 +2,7 @@ package com.github.swagger.enumeratum.converter
22
33import io .swagger .v3 .core .converter ._
44import io .swagger .v3 .oas .models .media ._
5- import models .{Ctx , ModelWCtxEnum , ModelWEnum , ModelWEnumAnnotated , ModelWEnumSet , ModelWOptionalEnum , OrderSize }
5+ import models .{Ctx , ModelWCtxEnum , ModelWCtxEnumAndAnnotation , ModelWEnum , ModelWEnumAnnotated , ModelWEnumSet , ModelWOptionalEnum , OrderSize }
66import org .scalatest .OptionValues
77import org .scalatest .flatspec .AnyFlatSpec
88import org .scalatest .matchers .should .Matchers
@@ -60,13 +60,33 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue
6060 it should " process Model for Enumeratum Enum defined in scope of another object" in {
6161 val converter = ModelConverters .getInstance()
6262 val schemas = converter.readAll(classOf [ModelWCtxEnum ]).asScala.toMap
63+ schemas.keys should have size 1
6364 val model = findModel(schemas, " ModelWCtxEnum" )
6465 model should be (defined)
6566 model.get.getProperties should not be (null )
6667 val field = model.value.getProperties.get(" field" )
6768 field shouldBe a [StringSchema ]
6869 val schema = field.asInstanceOf [StringSchema ]
6970 schema.getDescription shouldEqual (null )
71+ schema.getDefault should be (null )
72+ schema.getEnum.asScala shouldEqual Ctx .Color .values.map(_.entryName)
73+ nullSafeList(model.value.getRequired) shouldBe Seq (" field" )
74+ }
75+
76+ it should " not add additional model when enum field is annotated" in {
77+ val converter = ModelConverters .getInstance()
78+ val schemas = converter.readAll(classOf [ModelWCtxEnumAndAnnotation ]).asScala.toMap
79+ schemas.keys should have size 1
80+
81+ val model = findModel(schemas, " ModelWCtxEnum" )
82+ model should be(defined)
83+ model.get.getProperties should not be (null )
84+ val field = model.value.getProperties.get(" field" )
85+ field shouldBe a[StringSchema ]
86+ val schema = field.asInstanceOf [StringSchema ]
87+ schema.getDescription shouldEqual " An annotated field"
88+ schema.getName shouldEqual " field"
89+ schema.getDefault should be (null )
7090 schema.getEnum.asScala shouldEqual Ctx .Color .values.map(_.entryName)
7191 nullSafeList(model.value.getRequired) shouldBe Seq (" field" )
7292 }
0 commit comments