Skip to content

Commit a181f59

Browse files
committed
openapi-processor/openapi-processor-spring#157, additional parameter has no source type
1 parent 1ae20b9 commit a181f59

2 files changed

Lines changed: 26 additions & 2 deletions

File tree

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,9 @@ private fun DataType.shouldHaveValid(): Boolean {
153153
if (this is MappedCollectionDataType)
154154
return false
155155

156-
if (this is MappedSourceDataType)
157-
return sourceDataType!!.shouldHaveValid()
156+
if (this is MappedSourceDataType) {
157+
return sourceDataType?.shouldHaveValid() ?: false
158+
}
158159

159160
return false
160161
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,27 @@ class BeanValidationMappingSpec: StringSpec({
138138
io.annotations.shouldBeEmpty()
139139
}
140140

141+
"does not add @Valid to data type without source type (additional parameter)" {
142+
val dataType = MappedDataType(
143+
"Foo",
144+
"foo",
145+
emptyList(),
146+
emptyList(),
147+
null,
148+
false,
149+
null
150+
)
151+
152+
val info = validation.validate(dataType, false)
153+
154+
val prop = info.prop
155+
prop.dataTypeValue shouldBe "Foo"
156+
prop.imports.shouldBeEmpty()
157+
prop.annotations.shouldBeEmpty()
158+
159+
val io = info.inout
160+
io.dataTypeValue shouldBe "Foo"
161+
io.imports.shouldBeEmpty()
162+
io.annotations.shouldBeEmpty()
163+
}
141164
})

0 commit comments

Comments
 (0)