Skip to content

Commit eb01601

Browse files
committed
Merge branch 'master' into 1.2.x
Conflicts: gradle.properties
2 parents 509c71b + 7f246de commit eb01601

File tree

9 files changed

+102
-2
lines changed

9 files changed

+102
-2
lines changed

openapi-processor-core/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

openapi-processor-core/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' : [

openapi-processor-core/src/testInt/groovy/com/github/hauner/openapi/processor/core/ProcessorEndToEndTest.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class ProcessorEndToEndTest extends ProcessorTestBase {
3636
'ref-is-relative-to-current-file',
3737
'ref-parameter',
3838
'ref-parameter-with-primitive-mapping',
39+
'response-content-multiple-no-content'
3940
]
4041

4142
@Parameterized.Parameters(name = "{0}")

openapi-processor-core/src/testInt/groovy/com/github/hauner/openapi/processor/core/ProcessorPendingTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class ProcessorPendingTest extends ProcessorTestBase {
3232
@Parameterized.Parameters(name = "{0}")
3333
static Collection<TestSet> sources () {
3434
return [
35-
new TestSet(name: 'ref-is-relative-to-current-file', processor: new TestProcessor(), parser: ParserType.SWAGGER),
36-
new TestSet(name: 'ref-is-relative-to-current-file', processor: new TestProcessor(), parser: ParserType.OPENAPI4J)
35+
new TestSet(name: 'response-content-multiple-no-content', processor: new TestProcessor(), parser: ParserType.SWAGGER),
36+
new TestSet(name: 'response-content-multiple-no-content', processor: new TestProcessor(), parser: ParserType.OPENAPI4J)
3737
]
3838
}
3939

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
items:
2+
- generated/api/Api.java
3+
- generated/model/Foo.java
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* This class is auto generated by https://github.com/hauner/openapi-processor-core.
3+
* TEST ONLY.
4+
*/
5+
6+
package generated.api;
7+
8+
import annotation.Mapping;
9+
import generated.model.Foo;
10+
11+
public interface Api {
12+
13+
@Mapping("/foo")
14+
Foo getFoo();
15+
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* This class is auto generated by https://github.com/hauner/openapi-processor-core.
3+
* TEST ONLY.
4+
*/
5+
6+
package generated.model;
7+
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
public class Foo {
11+
12+
@JsonProperty("bar")
13+
private String bar;
14+
15+
public String getBar() {
16+
return bar;
17+
}
18+
19+
public void setBar(String bar) {
20+
this.bar = bar;
21+
}
22+
23+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
items:
2+
- inputs/openapi.yaml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
openapi: 3.0.3
2+
info:
3+
title: test response content with multiple no content errors
4+
version: 1.0.0
5+
6+
paths:
7+
/foo:
8+
get:
9+
responses:
10+
'200':
11+
description: json or plain text result
12+
content:
13+
application/json:
14+
schema:
15+
$ref: '#/components/schemas/Foo'
16+
'400':
17+
description: Bad request.
18+
'401':
19+
description: Unauthorized.
20+
'404':
21+
description: Not found.
22+
'5XX':
23+
description: Server error.
24+
25+
components:
26+
schemas:
27+
Foo:
28+
type: object
29+
properties:
30+
bar:
31+
type: string

0 commit comments

Comments
 (0)