File tree 12 files changed +274
-1
lines changed
openapi-processor-core/src
main/kotlin/io/openapiprocessor/core/converter
response-result-multiple/inputs
response-result-multiple-object
12 files changed +274
-1
lines changed Original file line number Diff line number Diff line change @@ -236,6 +236,10 @@ class ApiConverter(
236
236
237
237
private fun collectContentTypeInterfaces (responses : Map <HttpStatus , Response >, ctx : ApiConverterContext )
238
238
: Map <ContentType , ContentTypeInterface > {
239
+ if (! options.responseInterface) {
240
+ return emptyMap()
241
+ }
242
+
239
243
val resultStyle = getResultStyle(ctx.path, ctx.method)
240
244
val responseCollector = ContentTypeResponseCollector (responses, resultStyle)
241
245
Original file line number Diff line number Diff line change
1
+ items :
2
+ - inputs/openapi30.yaml
3
+ - inputs/openapi31.yaml
4
+ - inputs/mapping.yaml
Original file line number Diff line number Diff line change
1
+ openapi-processor-mapping : v12
2
+
3
+ options :
4
+ package-name : generated
5
+ format-code : false
6
+ response-interface : false
Original file line number Diff line number Diff line change
1
+ openapi : 3.0.2
2
+ info :
3
+ title : test multiple success responses
4
+ version : 1.0.0
5
+
6
+ paths :
7
+
8
+ /foo :
9
+ get :
10
+ description : endpoint returns Foo
11
+ responses :
12
+ ' 200 ' :
13
+ description : success
14
+ content :
15
+ application/json :
16
+ schema :
17
+ $ref : ' #/components/schemas/Foo'
18
+ text/plain :
19
+ schema :
20
+ type : string
21
+ ' 202 ' :
22
+ description : another success
23
+ content :
24
+ application/json :
25
+ schema :
26
+ $ref : ' #/components/schemas/Foo'
27
+
28
+ /fooBarA :
29
+ get :
30
+ description : endpoint returns interface A
31
+ responses :
32
+ ' 200 ' :
33
+ description : success
34
+ content :
35
+ application/json :
36
+ schema :
37
+ $ref : ' #/components/schemas/Foo'
38
+ text/plain :
39
+ schema :
40
+ type : string
41
+ ' 202 ' :
42
+ description : another success
43
+ content :
44
+ application/json :
45
+ schema :
46
+ $ref : ' #/components/schemas/Bar'
47
+
48
+ /fooBarB :
49
+ get :
50
+ description : endpoint returns interface B
51
+ responses :
52
+ ' 200 ' :
53
+ description : success
54
+ content :
55
+ application/json :
56
+ schema :
57
+ $ref : ' #/components/schemas/Foo'
58
+ text/plain :
59
+ schema :
60
+ type : string
61
+ ' 202 ' :
62
+ description : another success
63
+ content :
64
+ application/json :
65
+ schema :
66
+ $ref : ' #/components/schemas/Bar'
67
+
68
+ components :
69
+ schemas :
70
+
71
+ Foo :
72
+ description : implements interface A & B
73
+ type : object
74
+ properties :
75
+ foo :
76
+ type : string
77
+
78
+ Bar :
79
+ description : implements interface A & B
80
+ type : object
81
+ properties :
82
+ bar :
83
+ type : string
Original file line number Diff line number Diff line change
1
+ openapi : 3.1.0
2
+ info :
3
+ title : test multiple success responses
4
+ version : 1.0.0
5
+
6
+ paths :
7
+
8
+ /foo :
9
+ get :
10
+ description : endpoint returns Foo
11
+ responses :
12
+ ' 200 ' :
13
+ description : success
14
+ content :
15
+ application/json :
16
+ schema :
17
+ $ref : ' #/components/schemas/Foo'
18
+ text/plain :
19
+ schema :
20
+ type : string
21
+ ' 202 ' :
22
+ description : another success
23
+ content :
24
+ application/json :
25
+ schema :
26
+ $ref : ' #/components/schemas/Foo'
27
+
28
+ /fooBarA :
29
+ get :
30
+ description : endpoint returns interface A
31
+ responses :
32
+ ' 200 ' :
33
+ description : success
34
+ content :
35
+ application/json :
36
+ schema :
37
+ $ref : ' #/components/schemas/Foo'
38
+ text/plain :
39
+ schema :
40
+ type : string
41
+ ' 202 ' :
42
+ description : another success
43
+ content :
44
+ application/json :
45
+ schema :
46
+ $ref : ' #/components/schemas/Bar'
47
+
48
+ /fooBarB :
49
+ get :
50
+ description : endpoint returns interface B
51
+ responses :
52
+ ' 200 ' :
53
+ description : success
54
+ content :
55
+ application/json :
56
+ schema :
57
+ $ref : ' #/components/schemas/Foo'
58
+ text/plain :
59
+ schema :
60
+ type : string
61
+ ' 202 ' :
62
+ description : another success
63
+ content :
64
+ application/json :
65
+ schema :
66
+ $ref : ' #/components/schemas/Bar'
67
+
68
+ components :
69
+ schemas :
70
+
71
+ Foo :
72
+ description : implements interface A & B
73
+ type : object
74
+ properties :
75
+ foo :
76
+ type : string
77
+
78
+ Bar :
79
+ description : implements interface A & B
80
+ type : object
81
+ properties :
82
+ bar :
83
+ type : string
Original file line number Diff line number Diff line change
1
+ items :
2
+ - outputs/api/Api.java
3
+ - outputs/<model>/Foo.java
4
+ - outputs/<model>/Bar.java
Original file line number Diff line number Diff line change
1
+ package generated .api ;
2
+
3
+ import annotation .Mapping ;
4
+ import generated .model .Foo ;
5
+ import generated .support .Generated ;
6
+
7
+ @ Generated (value = "openapi-processor-core" , version = "test" )
8
+ public interface Api {
9
+
10
+ @ Mapping ("/foo" )
11
+ Foo getFooApplicationJson ();
12
+
13
+ @ Mapping ("/foo" )
14
+ String getFooTextPlain ();
15
+
16
+ @ Mapping ("/fooBarA" )
17
+ Object getFooBarAApplicationJson ();
18
+
19
+ @ Mapping ("/fooBarA" )
20
+ String getFooBarATextPlain ();
21
+
22
+ @ Mapping ("/fooBarB" )
23
+ Object getFooBarBApplicationJson ();
24
+
25
+ @ Mapping ("/fooBarB" )
26
+ String getFooBarBTextPlain ();
27
+
28
+ }
Original file line number Diff line number Diff line change
1
+ package generated .model ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonProperty ;
4
+ import generated .support .Generated ;
5
+
6
+ @ Generated (value = "openapi-processor-core" , version = "test" )
7
+ public class Bar {
8
+
9
+ @ JsonProperty ("bar" )
10
+ private String bar ;
11
+
12
+ public String getBar () {
13
+ return bar ;
14
+ }
15
+
16
+ public void setBar (String bar ) {
17
+ this .bar = bar ;
18
+ }
19
+
20
+ }
Original file line number Diff line number Diff line change
1
+ package generated .model ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonProperty ;
4
+ import generated .support .Generated ;
5
+
6
+ @ Generated (value = "openapi-processor-core" , version = "test" )
7
+ public class Foo {
8
+
9
+ @ JsonProperty ("foo" )
10
+ private String foo ;
11
+
12
+ public String getFoo () {
13
+ return foo ;
14
+ }
15
+
16
+ public void setFoo (String foo ) {
17
+ this .foo = foo ;
18
+ }
19
+
20
+ }
Original file line number Diff line number Diff line change
1
+ package generated .model ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonProperty ;
4
+ import generated .support .Generated ;
5
+
6
+ @ Generated (value = "openapi-processor-core" , version = "test" )
7
+ public record Bar (
8
+ @ JsonProperty ("bar" )
9
+ String bar
10
+ ) {}
Original file line number Diff line number Diff line change
1
+ package generated .model ;
2
+
3
+ import com .fasterxml .jackson .annotation .JsonProperty ;
4
+ import generated .support .Generated ;
5
+
6
+ @ Generated (value = "openapi-processor-core" , version = "test" )
7
+ public record Foo (
8
+ @ JsonProperty ("foo" )
9
+ String foo
10
+ ) {}
Original file line number Diff line number Diff line change 1
- openapi-processor-mapping : v11
1
+ openapi-processor-mapping : v12
2
2
3
3
options :
4
4
package-name : generated
5
5
format-code : false
6
+ response-interface : true
You can’t perform that action at this time.
0 commit comments