Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit 8abab2b

Browse files
committed
#78, annotate interface property when bean validation is enabled
1 parent e9ceee3 commit 8abab2b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/main/kotlin/io/openapiprocessor/core/writer/java/BeanValidationFactory.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ open class BeanValidationFactory {
7575
private fun collectAnnotations(dataType: DataType, required: Boolean = false): List<String> {
7676
val annotations = mutableListOf<String>()
7777

78-
if (dataType.isModel() || dataType.isArrayOfModel()) {
78+
if (dataType.isModel() || dataType.isInterface() || dataType.isArrayOfModel()) {
7979
annotations.add(BeanValidation.VALID.annotation)
8080
}
8181

@@ -107,7 +107,7 @@ open class BeanValidationFactory {
107107
}
108108

109109
private fun requiresValidImport(dataType: DataType): Boolean {
110-
if (dataType.isModel())
110+
if (dataType.isModel() || dataType.isInterface())
111111
return true
112112

113113
if (dataType !is CollectionDataType)
@@ -167,6 +167,8 @@ open class BeanValidationFactory {
167167

168168
private fun DataType.isModel(): Boolean = this is ModelDataType
169169

170+
private fun DataType.isInterface(): Boolean = this is InterfaceDataType
171+
170172
private fun DataType.isArrayOfModel(): Boolean {
171173
if (this !is ArrayDataType)
172174
return false

0 commit comments

Comments
 (0)