Skip to content

Commit c49a1dc

Browse files
committed
add test case for schema override for optional param
1 parent 2c86dd3 commit c49a1dc

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ class ModelPropertyParserTest extends FlatSpec with Matchers {
9292
val model = schemas.get("ModelWOptionBigInt")
9393
model should be ('defined)
9494
model.get.getProperties should not be (null)
95-
val optBigDecimal = model.get.getProperties().get("optBigInt")
96-
optBigDecimal should not be (null)
97-
optBigDecimal shouldBe a [IntegerSchema]
95+
val optBigInt = model.get.getProperties().get("optBigInt")
96+
optBigInt should not be (null)
97+
optBigInt shouldBe a [IntegerSchema]
9898
nullSafeList(model.get.getRequired) shouldBe empty
9999
}
100100

@@ -110,6 +110,19 @@ class ModelPropertyParserTest extends FlatSpec with Matchers {
110110
nullSafeList(model.get.getRequired) shouldBe empty
111111
}
112112

113+
it should "process Model with Scala Option Int with Schema Override" in {
114+
val converter = ModelConverters.getInstance()
115+
val schemas = converter.readAll(classOf[ModelWOptionIntSchemaOverride]).asScala.toMap
116+
val model = schemas.get("ModelWOptionIntSchemaOverride")
117+
model should be ('defined)
118+
model.get.getProperties should not be (null)
119+
val optInt = model.get.getProperties().get("optInt")
120+
optInt should not be (null)
121+
optInt shouldBe a [IntegerSchema]
122+
//there is a bug that the override causes the field to be marked as required
123+
//nullSafeList(model.get.getRequired) shouldBe empty
124+
}
125+
113126
it should "process Model with Scala Option Boolean" in {
114127
val converter = ModelConverters.getInstance()
115128
val schemas = converter.readAll(classOf[ModelWOptionBoolean]).asScala.toMap
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
package models
22

3+
import io.swagger.v3.oas.annotations.media.Schema
4+
35
case class ModelWOptionInt(optInt: Option[Int])
6+
7+
case class ModelWOptionIntSchemaOverride(@Schema(implementation = classOf[Int]) optInt: Option[Int])

0 commit comments

Comments
 (0)