Skip to content

Commit eece96a

Browse files
committed
add test
1 parent f30f063 commit eece96a

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/test/scala/com/github/swagger/scala/converter/ModelPropertyParserTest.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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]

src/test/scala/models/ModelWBigDecimalAnnotated.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
)

0 commit comments

Comments
 (0)