Skip to content

Commit 6258519

Browse files
committed
simpler
1 parent 5795831 commit 6258519

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,22 @@ class ContentTypeInterfaceCollector(
3232
var dataType: DataType? = null
3333
statusResponse.forEach { (status, _) ->
3434
val match = statusResultResponses[status]?.find { r -> r.contentType == contentType }
35-
if (match != null) {
36-
if (dataType == null) {
37-
dataType = match.responseType
38-
} else {
39-
if (match.responseType !== dataType && match.responseType !is SimpleDataType) {
40-
contentTypeInterfaces[contentType] = ContentTypeInterface(path, method)
41-
return@forEach
42-
}
43-
}
35+
if (match == null) {
36+
return@forEach
37+
}
38+
39+
if (dataType == null) {
40+
dataType = match.responseType
41+
42+
} else if (isAdditionalContentType(match, dataType)) {
43+
contentTypeInterfaces[contentType] = ContentTypeInterface(path, method)
4444
}
4545
}
4646
}
4747

4848
return contentTypeInterfaces
4949
}
50+
51+
private fun isAdditionalContentType(match: ModelResponse, dataType: DataType): Boolean
52+
= match.responseType !== dataType && match.responseType !is SimpleDataType
5053
}

0 commit comments

Comments
 (0)