@@ -17,10 +17,12 @@ import scala.reflect.ClassTag
1717class ModelPropertyParserTest extends AnyFlatSpec with BeforeAndAfterEach with Matchers with OptionValues {
1818 override protected def beforeEach () = {
1919 SwaggerScalaModelConverter .setRequiredBasedOnAnnotation(true )
20+ SwaggerScalaModelConverter .setRequiredBasedOnDefaultValue(true )
2021 }
2122
2223 override protected def afterEach () = {
2324 SwaggerScalaModelConverter .setRequiredBasedOnAnnotation(true )
25+ SwaggerScalaModelConverter .setRequiredBasedOnDefaultValue(true )
2426 }
2527
2628 trait TestScope {
@@ -389,6 +391,7 @@ class ModelPropertyParserTest extends AnyFlatSpec with BeforeAndAfterEach with M
389391
390392 it should " process Model with Scala BigDecimal with annotation" in new PropertiesScope [ModelWBigDecimalAnnotated ]() {
391393 val fieldSchema = model.value.getProperties.get(" field" )
394+ fieldSchema.getDeprecated shouldBe java.lang.Boolean .TRUE
392395 fieldSchema shouldBe a[StringSchema ]
393396 fieldSchema.asInstanceOf [StringSchema ].getExample shouldEqual (" 42.0" )
394397 nullSafeSeq(model.value.getRequired) shouldEqual Seq (" field" )
@@ -397,6 +400,7 @@ class ModelPropertyParserTest extends AnyFlatSpec with BeforeAndAfterEach with M
397400 it should " map BigDecimal to schema type 'number'" in new PropertiesScope [ModelWBigDecimalNoType ]() {
398401 val properties = model.value.getProperties
399402 val fieldSchema = properties.get(" field" )
403+ fieldSchema.getDeprecated shouldBe null
400404 properties should have size 1
401405
402406 fieldSchema shouldBe a[NumberSchema ]
@@ -470,17 +474,27 @@ class ModelPropertyParserTest extends AnyFlatSpec with BeforeAndAfterEach with M
470474 it should " default to supplied schema if it can't be corrected" in new PropertiesScope [ModelWMapStringCaseClass ] {
471475 schemas should have size 2
472476
477+ nullSafeSeq(model.value.getRequired) shouldBe empty
473478 val mapField = model.value.getProperties.get(" maybeMapStringCaseClass" )
474479 mapField shouldBe a[MapSchema ]
475480 mapField.getAdditionalProperties shouldBe a[Schema [_]]
476481 mapField.getAdditionalProperties.asInstanceOf [Schema [_]].get$ref() shouldBe " #/components/schemas/SomeCaseClass"
477482
478-
479483 val caseClassField = schemas(" SomeCaseClass" )
480484 caseClassField shouldBe a[Schema [_]]
481485 caseClassField.getProperties.get(" field" ) shouldBe an[IntegerSchema ]
482486 }
483487
488+ it should " handle Option[Map[String, Long]]" in new PropertiesScope [ModelWMapStringLong ] {
489+ schemas should have size 1
490+
491+ nullSafeSeq(model.value.getRequired) shouldBe empty
492+ val mapField = model.value.getProperties.get(" maybeMapStringLong" )
493+ mapField shouldBe a[MapSchema ]
494+ nullSafeMap(mapField.getProperties) shouldBe empty
495+ mapField.getAdditionalProperties shouldBe a[Schema [_]]
496+ }
497+
484498 it should " process Model with Scala Seq" in new PropertiesScope [ModelWSeqString ] {
485499 schemas should have size 1
486500 val stringsField = model.value.getProperties.get(" strings" )
0 commit comments