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
515515 RouterFunctionData routerFunctionData = routerFunctionDataList .get (0 );
516516 if (ArrayUtils .isEmpty (routerOperation .getConsumes ()))
517517 routerOperation .setConsumes (routerFunctionData .getConsumes ());
518+ if (ArrayUtils .isEmpty (routerOperation .getProduces ()))
519+ routerOperation .setProduces (routerFunctionData .getProduces ());
518520 if (ArrayUtils .isEmpty (routerOperation .getHeaders ()))
519521 routerOperation .setHeaders (routerFunctionData .getHeaders ());
520522 if (ArrayUtils .isEmpty (routerOperation .getMethod ()))
Original file line number Diff line number Diff line change @@ -35,6 +35,8 @@ public class RouterFunctionData {
3535
3636 private String [] consumes ;
3737
38+ private String [] produces ;
39+
3840 private String [] headers ;
3941
4042 private String queryParam ;
@@ -94,13 +96,27 @@ public void setConsumes(String consumes) {
9496 if (StringUtils .isNotBlank (consumes ))
9597 this .consumes = new String [] { consumes };
9698 }
99+
100+ public void setProduces (String produces ) {
101+ if (StringUtils .isNotBlank (produces ))
102+ this .produces = new String [] { produces };
103+ }
104+
97105 private RequestMethod [] getMethod (Set <HttpMethod > methods ) {
98106 if (!CollectionUtils .isEmpty (methods )) {
99107 return methods .stream ().map (this ::getRequestMethod ).toArray (RequestMethod []::new );
100108 }
101109 return ArrayUtils .toArray ();
102110 }
103111
112+ public String [] getProduces () {
113+ return produces ;
114+ }
115+
116+ public void setProduces (String [] produces ) {
117+ this .produces = produces ;
118+ }
119+
104120 private RequestMethod getRequestMethod (HttpMethod httpMethod ) {
105121 RequestMethod requestMethod = null ;
106122 switch (httpMethod ) {
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ public RouterOperation(org.springdoc.core.annotations.RouterOperation routerOper
6363 this .path = StringUtils .isBlank (routerOperationAnnotation .path ()) ? routerFunctionData .getPath () : routerOperationAnnotation .path ();
6464 this .method = ArrayUtils .isEmpty (routerOperationAnnotation .method ()) ? routerFunctionData .getMethods () : routerOperationAnnotation .method ();
6565 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 ();
6767 this .beanClass = routerOperationAnnotation .beanClass ();
6868 this .beanMethod = routerOperationAnnotation .beanMethod ();
6969 this .parameterTypes = routerOperationAnnotation .parameterTypes ();
Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ public void path(String pattern) {
4545
4646 public void header (String name , String value ) {
4747 if (HttpHeaders .ACCEPT .equals (name ))
48+ routerFunctionData .setProduces (value );
49+ else if (HttpHeaders .CONTENT_TYPE .equals (name ))
4850 routerFunctionData .setConsumes (value );
4951 else
5052 routerFunctionData .setHeaders (name + "=" + value );
Original file line number Diff line number Diff line change 2222 "200" : {
2323 "description" : " OK" ,
2424 "content" : {
25- "*/* " : {
25+ "application/json " : {
2626 "schema" : {
2727 "type" : " array" ,
2828 "items" : {
5757 "200" : {
5858 "description" : " OK" ,
5959 "content" : {
60- "*/* " : {
60+ "application/json " : {
6161 "schema" : {
6262 "$ref" : " #/components/schemas/User"
6363 }
119119 "200" : {
120120 "description" : " OK" ,
121121 "content" : {
122- "*/* " : {
122+ "application/json " : {
123123 "schema" : {
124124 "$ref" : " #/components/schemas/User"
125125 }
150150 "200" : {
151151 "description" : " OK" ,
152152 "content" : {
153- "*/* " : {
153+ "application/json " : {
154154 "schema" : {
155155 "type" : " string"
156156 }
Original file line number Diff line number Diff line change 2121 "200" : {
2222 "description" : " OK" ,
2323 "content" : {
24- "*/* " : {
24+ "application/json " : {
2525 "schema" : {
2626 "type" : " array" ,
2727 "items" : {
8080 "operationId" : " updateEmployee" ,
8181 "requestBody" : {
8282 "content" : {
83- "application/xml " : {
83+ "application/json " : {
8484 "schema" : {
8585 "$ref" : " #/components/schemas/Employee"
8686 }
9191 "200" : {
9292 "description" : " OK" ,
9393 "content" : {
94- "*/* " : {
94+ "application/xml " : {
9595 "schema" : {
9696 "$ref" : " #/components/schemas/Employee"
9797 }
Original file line number Diff line number Diff line change 2121 "200" : {
2222 "description" : " OK" ,
2323 "content" : {
24- "*/* " : {
24+ "application/json " : {
2525 "schema" : {
2626 "type" : " array" ,
2727 "items" : {
5454 "200" : {
5555 "description" : " OK" ,
5656 "content" : {
57- "*/* " : {
57+ "application/stream+json " : {
5858 "schema" : {
5959 "$ref" : " #/components/schemas/Person"
6060 }
8383 "200" : {
8484 "description" : " OK" ,
8585 "content" : {
86- "*/* " : {
86+ "application/json " : {
8787 "schema" : {
8888 "type" : " string"
8989 }
113113 "200" : {
114114 "description" : " OK" ,
115115 "content" : {
116- "*/* " : {
116+ "application/json " : {
117117 "schema" : {
118118 "type" : " string"
119119 }
134134 "200" : {
135135 "description" : " default response" ,
136136 "content" : {
137- "*/* " : {
137+ "application/json " : {
138138 "schema" : {
139139 "type" : " array" ,
140140 "items" : {
168168 "200" : {
169169 "description" : " default response" ,
170170 "content" : {
171- "*/* " : {
171+ "application/stream+json " : {
172172 "schema" : {
173173 "$ref" : " #/components/schemas/Position"
174174 }
187187 "operationId" : " save_1" ,
188188 "requestBody" : {
189189 "content" : {
190- "application/json " : {
190+ "*/* " : {
191191 "schema" : {
192192 "$ref" : " #/components/schemas/Position"
193193 }
198198 "200" : {
199199 "description" : " default response" ,
200200 "content" : {
201- "*/* " : {
201+ "application/json " : {
202202 "schema" : {
203203 "$ref" : " #/components/schemas/Position"
204204 }
You can’t perform that action at this time.
0 commit comments