File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
com/github/swagger/scala/converter Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -358,6 +358,21 @@ class ModelPropertyParserTest extends AnyFlatSpec with BeforeAndAfterEach with M
358358 nullSafeSeq(model.value.getRequired) shouldEqual Seq (" field" )
359359 }
360360
361+ it should " process Model with Scala BigDecimal with default value annotation (required=false)" in new PropertiesScope [
362+ ModelWBigDecimalAnnotatedDefaultRequiredFalse
363+ ](
364+ false
365+ ) {
366+ val fieldSchema = model.value.getProperties.get(" field" )
367+ fieldSchema shouldBe a[StringSchema ]
368+ val stringSchema = fieldSchema.asInstanceOf [StringSchema ]
369+ stringSchema.getDefault shouldEqual (" 42.0" )
370+ stringSchema.getExample shouldEqual (" 42.0" )
371+ stringSchema.getDescription shouldBe " required of annotation should be honoured"
372+
373+ nullSafeSeq(model.value.getRequired) shouldBe empty
374+ }
375+
361376 it should " process Model with Scala BigInt with annotation" in new PropertiesScope [ModelWBigIntAnnotated ] {
362377 val field = model.value.getProperties.get(" field" )
363378 field shouldBe a[StringSchema ]
Original file line number Diff line number Diff line change @@ -18,3 +18,13 @@ case class ModelWBigDecimalAnnotatedDefault(
1818 required = true
1919 ) field : BigDecimal = BigDecimal .valueOf(0 )
2020)
21+
22+ case class ModelWBigDecimalAnnotatedDefaultRequiredFalse (
23+ @ Schema (
24+ description = " required of annotation should be honoured" ,
25+ `type` = " string" ,
26+ example = " 42.0" ,
27+ defaultValue = " 42.0" ,
28+ required = false
29+ ) field : BigDecimal = BigDecimal .valueOf(0 )
30+ )
You can’t perform that action at this time.
0 commit comments