Skip to content

Commit cf16f7a

Browse files
committed
prepare interface for multiple responses (#247)
1 parent ea4a21e commit cf16f7a

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright 2025 https://github.com/openapi-processor/openapi-processor-base
3+
* PDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.openapiprocessor.core.converter
7+
8+
import io.openapiprocessor.core.parser.HttpMethod
9+
10+
class ContentTypeInterface(val path: String, val method: HttpMethod)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2025 https://github.com/openapi-processor/openapi-processor-base
3+
* PDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.openapiprocessor.core.converter
7+
8+
import io.openapiprocessor.core.parser.ContentType
9+
import io.openapiprocessor.core.parser.HttpMethod
10+
import io.openapiprocessor.core.parser.HttpStatus
11+
import io.openapiprocessor.core.parser.Response
12+
13+
class ContentTypeInterfaceCollector(
14+
private val path: String,
15+
private val method: HttpMethod,
16+
responseCollector: ContentTypeResponseCollector
17+
) {
18+
val contentTypeInterfaces: Map<String, ContentTypeInterface> = collectInterfaces(
19+
responseCollector.contentTypeResponses
20+
)
21+
22+
private fun collectInterfaces(contentTypeResponses: Map<ContentType, Map<HttpStatus, Response>>)
23+
: Map<String, ContentTypeInterface> {
24+
val contentTypeInterfaces = mutableMapOf<String, ContentTypeInterface>()
25+
26+
contentTypeResponses.forEach { (contentType, statusResponses) ->
27+
if (statusResponses.size > 1) {
28+
contentTypeInterfaces[contentType] = ContentTypeInterface(path, method)
29+
}
30+
}
31+
32+
return contentTypeInterfaces
33+
}
34+
}

0 commit comments

Comments
 (0)