@@ -3,6 +3,7 @@ package com.github.swagger.scala.converter
33import io .swagger .v3 .core .converter ._
44import io .swagger .v3 .core .util .Json
55import io .swagger .v3 .oas .models .media ._
6+ import models .NestingObject .NestedModelWOptionInt
67import models ._
78import org .scalatest .OptionValues
89import org .scalatest .flatspec .AnyFlatSpec
@@ -117,6 +118,41 @@ class ModelPropertyParserTest extends AnyFlatSpec with Matchers with OptionValue
117118 nullSafeList(model.value.getRequired) shouldBe empty
118119 }
119120
121+ it should " process Model with nested Scala Option Int" in {
122+ val converter = ModelConverters .getInstance()
123+ val schemas = converter.readAll(classOf [NestedModelWOptionInt ]).asScala.toMap
124+ val model = schemas.get(" NestedModelWOptionInt" )
125+ model should be(defined)
126+ model.value.getProperties should not be (null )
127+ val optInt = model.value.getProperties().get(" optInt" )
128+ optInt should not be (null )
129+ if (RuntimeUtil .isScala3()) {
130+ optInt shouldBe a[ObjectSchema ]
131+ } else {
132+ optInt shouldBe a[IntegerSchema ]
133+ optInt.asInstanceOf [IntegerSchema ].getFormat shouldEqual " int32"
134+ }
135+ nullSafeList(model.value.getRequired) shouldBe empty
136+ }
137+
138+ it should " process Model with nested Scala Option Int with Schema Override" in {
139+ val converter = ModelConverters .getInstance()
140+ val schemas = converter.readAll(classOf [ModelWOptionIntSchemaOverride ]).asScala.toMap
141+ val model = schemas.get(" ModelWOptionIntSchemaOverride" )
142+ model should be(defined)
143+ model.value.getProperties should not be (null )
144+ val optInt = model.value.getProperties().get(" optInt" )
145+ optInt should not be (null )
146+ if (RuntimeUtil .isScala3()) {
147+ optInt shouldBe a[ObjectSchema ]
148+ } else {
149+ optInt shouldBe a[IntegerSchema ]
150+ optInt.asInstanceOf [IntegerSchema ].getFormat shouldEqual " int32"
151+ }
152+ optInt.getDescription shouldBe " This is an optional int"
153+ nullSafeList(model.value.getRequired) shouldBe empty
154+ }
155+
120156 it should " process Model with Scala Option Int with Schema Override" in {
121157 val converter = ModelConverters .getInstance()
122158 val schemas = converter.readAll(classOf [ModelWOptionIntSchemaOverride ]).asScala.toMap
0 commit comments