Skip to content

Commit 4c7efae

Browse files
committed
ignore primitive data type (#247)
1 parent 6e5c3a5 commit 4c7efae

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/converter/ContentTypeInterfaceCollector.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package io.openapiprocessor.core.converter
77

88
import io.openapiprocessor.core.model.datatypes.DataType
9+
import io.openapiprocessor.core.model.datatypes.SimpleDataType
910
import io.openapiprocessor.core.parser.ContentType
1011
import io.openapiprocessor.core.parser.HttpMethod
1112
import io.openapiprocessor.core.parser.HttpStatus
@@ -29,13 +30,13 @@ class ContentTypeInterfaceCollector(
2930
}
3031

3132
var dataType: DataType? = null
32-
statusResponse.forEach { (status, response) ->
33+
statusResponse.forEach { (status, _) ->
3334
val match = statusResultResponses[status]?.find { r -> r.contentType == contentType }
3435
if (match != null) {
3536
if (dataType == null) {
3637
dataType = match.responseType
3738
} else {
38-
if (match.responseType !== dataType) {
39+
if (match.responseType !== dataType && match.responseType !is SimpleDataType) {
3940
contentTypeInterfaces[contentType] = ContentTypeInterface(path, method)
4041
return@forEach
4142
}

openapi-processor-core/src/test/kotlin/io/openapiprocessor/core/converter/ContentTypeInterfaceCollectorSpec.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,21 @@ class ContentTypeInterfaceCollectorSpec: StringSpec({
124124
cti["application/json"].shouldNotBeNull()
125125
}
126126

127+
"returns interface result with different response data types, with primitve" {
128+
val collector = ContentTypeInterfaceCollector("/foo", HttpMethod.GET)
129+
130+
val ctr = mutableMapOf<ContentType, Map<HttpStatus, Response>>()
131+
ctr["application/json"] = mapOf(
132+
"200" to mockk<Response>(),
133+
"201" to mockk<Response>(),
134+
)
135+
136+
val srr = mutableMapOf<HttpStatus, List<ModelResponse>>()
137+
srr["200"] = listOf(ModelResponse("application/json", foo))
138+
srr["201"] = listOf(ModelResponse("application/json", StringDataType()))
139+
140+
val cti = collector.collectContentTypeInterfaces(ctr, srr)
141+
142+
cti.shouldBeEmpty()
143+
}
127144
})

0 commit comments

Comments
 (0)