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

Commit be961aa

Browse files
committed
fix empty response leak
1 parent ce6331b commit be961aa

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/main/kotlin/io/openapiprocessor/core/model/Endpoint.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ class Endpoint(
227227
.filterKeys { !it.startsWith("2") }
228228
.values
229229
.map { it.first() }
230+
.filter { !it.empty }
230231
.toSet()
231232
}
232233

src/test/groovy/com/github/hauner/openapi/core/writer/java/MethodWriterSpec.groovy

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,29 @@ class MethodWriterSpec extends Specification {
307307
"""
308308
}
309309
310+
void "writes method with success response type when it has only empty error responses" () {
311+
def endpoint = createEndpoint (path: '/foo', method: HttpMethod.GET, responses: [
312+
'200' : [
313+
new Response ('application/json', new StringDataType ())
314+
],
315+
'400': [
316+
new EmptyResponse ()
317+
],
318+
'500': [
319+
new EmptyResponse ()
320+
]
321+
])
322+
323+
when:
324+
writer.write (target, endpoint, endpoint.endpointResponses.first ())
325+
326+
then:
327+
target.toString () == """\
328+
@CoreMapping
329+
String getFoo();
330+
"""
331+
}
332+
310333
void "writes method with 'Object' response when it has multiple result content types (200, default)" () {
311334
def endpoint = createEndpoint (path: '/foo', method: HttpMethod.GET, responses: [
312335
'200' : [

0 commit comments

Comments
 (0)