Skip to content

Commit ae08a9a

Browse files
committed
call Class.forName() without generic parameters in the class name (openapi-processor/openapi-processor-spring#480)
1 parent 11e20db commit ae08a9a

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/writer/java/BeanValidationSupportedTypes.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,16 @@ class BeanValidationSupportedTypes(additionalSupportedTypes: SupportedTypes = ma
4242

4343
private fun getCanonicalName(targetDataType: DataType): String {
4444
val pkg = targetDataType.getPackageName()
45-
val name = targetDataType.rawTypeName
45+
val name = targetDataType.rawTypeName.stripGenerics()
4646

4747
if (pkg.isEmpty()) {
4848
return name
4949
}
5050

5151
return "$pkg.$name"
5252
}
53+
54+
private fun String.stripGenerics(): String = substringBefore("<")
5355
}
5456

5557

openapi-processor-core/src/test/kotlin/io/openapiprocessor/core/writer/java/BeanValidationSupportedTypesSpec.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,11 @@ class BeanValidationSupportedTypesSpec : FreeSpec({
7171
MappedDataType("JsonNullable", "org.openapitools.jackson.nullable"))
7272
.shouldBeTrue()
7373
}
74+
75+
"supported types recognizes java.util.List<String> as java.util.Collection" {
76+
types.supports(
77+
annotations.SIZE,
78+
MappedCollectionDataType("List", "java.util", StringDataType()))
79+
.shouldBeTrue()
80+
}
7481
})

0 commit comments

Comments
 (0)