File tree Expand file tree Collapse file tree 7 files changed +36
-16
lines changed
springdoc-openapi-common/src/main/java/org/springdoc
springdoc-openapi-webflux-core/src/test/resources/results Expand file tree Collapse file tree 7 files changed +36
-16
lines changed Original file line number Diff line number Diff line change @@ -515,6 +515,8 @@ private void fillRouterOperation(List<RouterFunctionData> routerFunctionDataList
515
515
RouterFunctionData routerFunctionData = routerFunctionDataList .get (0 );
516
516
if (ArrayUtils .isEmpty (routerOperation .getConsumes ()))
517
517
routerOperation .setConsumes (routerFunctionData .getConsumes ());
518
+ if (ArrayUtils .isEmpty (routerOperation .getProduces ()))
519
+ routerOperation .setProduces (routerFunctionData .getProduces ());
518
520
if (ArrayUtils .isEmpty (routerOperation .getHeaders ()))
519
521
routerOperation .setHeaders (routerFunctionData .getHeaders ());
520
522
if (ArrayUtils .isEmpty (routerOperation .getMethod ()))
Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ public class RouterFunctionData {
35
35
36
36
private String [] consumes ;
37
37
38
+ private String [] produces ;
39
+
38
40
private String [] headers ;
39
41
40
42
private String queryParam ;
@@ -94,13 +96,27 @@ public void setConsumes(String consumes) {
94
96
if (StringUtils .isNotBlank (consumes ))
95
97
this .consumes = new String [] { consumes };
96
98
}
99
+
100
+ public void setProduces (String produces ) {
101
+ if (StringUtils .isNotBlank (produces ))
102
+ this .produces = new String [] { produces };
103
+ }
104
+
97
105
private RequestMethod [] getMethod (Set <HttpMethod > methods ) {
98
106
if (!CollectionUtils .isEmpty (methods )) {
99
107
return methods .stream ().map (this ::getRequestMethod ).toArray (RequestMethod []::new );
100
108
}
101
109
return ArrayUtils .toArray ();
102
110
}
103
111
112
+ public String [] getProduces () {
113
+ return produces ;
114
+ }
115
+
116
+ public void setProduces (String [] produces ) {
117
+ this .produces = produces ;
118
+ }
119
+
104
120
private RequestMethod getRequestMethod (HttpMethod httpMethod ) {
105
121
RequestMethod requestMethod = null ;
106
122
switch (httpMethod ) {
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ public RouterOperation(org.springdoc.core.annotations.RouterOperation routerOper
63
63
this .path = StringUtils .isBlank (routerOperationAnnotation .path ()) ? routerFunctionData .getPath () : routerOperationAnnotation .path ();
64
64
this .method = ArrayUtils .isEmpty (routerOperationAnnotation .method ()) ? routerFunctionData .getMethods () : routerOperationAnnotation .method ();
65
65
this .consumes = ArrayUtils .isEmpty (routerOperationAnnotation .consumes ()) ? routerFunctionData .getConsumes () : routerOperationAnnotation .consumes ();
66
- this .produces = routerOperationAnnotation .produces ();
66
+ this .produces = ArrayUtils . isEmpty ( routerOperationAnnotation . produces ()) ? routerFunctionData . getProduces () : routerOperationAnnotation .produces ();
67
67
this .beanClass = routerOperationAnnotation .beanClass ();
68
68
this .beanMethod = routerOperationAnnotation .beanMethod ();
69
69
this .parameterTypes = routerOperationAnnotation .parameterTypes ();
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ public void path(String pattern) {
45
45
46
46
public void header (String name , String value ) {
47
47
if (HttpHeaders .ACCEPT .equals (name ))
48
+ routerFunctionData .setProduces (value );
49
+ else if (HttpHeaders .CONTENT_TYPE .equals (name ))
48
50
routerFunctionData .setConsumes (value );
49
51
else
50
52
routerFunctionData .setHeaders (name + "=" + value );
Original file line number Diff line number Diff line change 22
22
"200" : {
23
23
"description" : " OK" ,
24
24
"content" : {
25
- "*/* " : {
25
+ "application/json " : {
26
26
"schema" : {
27
27
"type" : " array" ,
28
28
"items" : {
57
57
"200" : {
58
58
"description" : " OK" ,
59
59
"content" : {
60
- "*/* " : {
60
+ "application/json " : {
61
61
"schema" : {
62
62
"$ref" : " #/components/schemas/User"
63
63
}
119
119
"200" : {
120
120
"description" : " OK" ,
121
121
"content" : {
122
- "*/* " : {
122
+ "application/json " : {
123
123
"schema" : {
124
124
"$ref" : " #/components/schemas/User"
125
125
}
150
150
"200" : {
151
151
"description" : " OK" ,
152
152
"content" : {
153
- "*/* " : {
153
+ "application/json " : {
154
154
"schema" : {
155
155
"type" : " string"
156
156
}
Original file line number Diff line number Diff line change 21
21
"200" : {
22
22
"description" : " OK" ,
23
23
"content" : {
24
- "*/* " : {
24
+ "application/json " : {
25
25
"schema" : {
26
26
"type" : " array" ,
27
27
"items" : {
80
80
"operationId" : " updateEmployee" ,
81
81
"requestBody" : {
82
82
"content" : {
83
- "application/xml " : {
83
+ "application/json " : {
84
84
"schema" : {
85
85
"$ref" : " #/components/schemas/Employee"
86
86
}
91
91
"200" : {
92
92
"description" : " OK" ,
93
93
"content" : {
94
- "*/* " : {
94
+ "application/xml " : {
95
95
"schema" : {
96
96
"$ref" : " #/components/schemas/Employee"
97
97
}
Original file line number Diff line number Diff line change 21
21
"200" : {
22
22
"description" : " OK" ,
23
23
"content" : {
24
- "*/* " : {
24
+ "application/json " : {
25
25
"schema" : {
26
26
"type" : " array" ,
27
27
"items" : {
54
54
"200" : {
55
55
"description" : " OK" ,
56
56
"content" : {
57
- "*/* " : {
57
+ "application/stream+json " : {
58
58
"schema" : {
59
59
"$ref" : " #/components/schemas/Person"
60
60
}
83
83
"200" : {
84
84
"description" : " OK" ,
85
85
"content" : {
86
- "*/* " : {
86
+ "application/json " : {
87
87
"schema" : {
88
88
"type" : " string"
89
89
}
113
113
"200" : {
114
114
"description" : " OK" ,
115
115
"content" : {
116
- "*/* " : {
116
+ "application/json " : {
117
117
"schema" : {
118
118
"type" : " string"
119
119
}
134
134
"200" : {
135
135
"description" : " default response" ,
136
136
"content" : {
137
- "*/* " : {
137
+ "application/json " : {
138
138
"schema" : {
139
139
"type" : " array" ,
140
140
"items" : {
168
168
"200" : {
169
169
"description" : " default response" ,
170
170
"content" : {
171
- "*/* " : {
171
+ "application/stream+json " : {
172
172
"schema" : {
173
173
"$ref" : " #/components/schemas/Position"
174
174
}
187
187
"operationId" : " save_1" ,
188
188
"requestBody" : {
189
189
"content" : {
190
- "application/json " : {
190
+ "*/* " : {
191
191
"schema" : {
192
192
"$ref" : " #/components/schemas/Position"
193
193
}
198
198
"200" : {
199
199
"description" : " default response" ,
200
200
"content" : {
201
- "*/* " : {
201
+ "application/json " : {
202
202
"schema" : {
203
203
"$ref" : " #/components/schemas/Position"
204
204
}
You can’t perform that action at this time.
0 commit comments