Skip to content

Commit c6c8a2e

Browse files
authored
List is seen as scala class in scala 2.12 (#207)
* Reproduce problem in unit test * Make sure we're not dealing with a collection to prevent internal properties like empty, traversableOnce, etc. from appearing in the model
1 parent ebf14ea commit c6c8a2e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/main/scala/com/github/swagger/scala/converter/SwaggerScalaModelConverter.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class SwaggerScalaModelConverter extends ModelResolver(SwaggerScalaModelConverte
129129
resolve(nextType(baseType, `type`, javaType), context, chain)
130130
} else if (!annotatedOverrides.headOption.getOrElse(true)) {
131131
resolve(nextType(new AnnotatedTypeForOption(), `type`, javaType), context, chain)
132-
} else if (isScalaClass(cls)) {
132+
} else if (isScalaClass(cls) && !isIterable(cls)) {
133133
scalaClassSchema(cls, `type`, context, chain).getOrElse(None.orNull)
134134
} else if (chain.hasNext) {
135135
val nextResolved = Option(chain.next().resolve(`type`, context, chain))

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,9 +458,10 @@ class ModelPropertyParserTest extends AnyFlatSpec with BeforeAndAfterEach with M
458458
model should be(defined)
459459
model.value.getProperties should not be (null)
460460
val stringsField = model.value.getProperties.get("items")
461-
stringsField shouldBe a[ArraySchema]
461+
stringsField shouldBe an[ArraySchema]
462462
val arraySchema = stringsField.asInstanceOf[ArraySchema]
463-
arraySchema.getUniqueItems() shouldBe (null)
463+
arraySchema.getUniqueItems shouldBe null
464+
arraySchema.getRequired shouldBe null
464465
arraySchema.getItems shouldBe a[ObjectSchema] // probably type erasure - ideally this would eval as StringSchema
465466
// next line used to fail (https://github.com/swagger-akka-http/swagger-akka-http/issues/171)
466467
Json.mapper().writeValueAsString(model.value)

0 commit comments

Comments
 (0)