1- = (global) Single & Multi mapping
1+ :responseentity: https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/http/ResponseEntity.html
22
3- NOTE: this is experimental
3+ = (global) Single & Multi mapping
44
55== single & multi wrapper
66
3838
3939The processor will now wrap all non-array like response types with the given `single` mapping.
4040
41+ == endpoint specific mapping
42+
43+ it is also possible to configure `single` & `multi` on the xref:mapping/endpoint.adoc[endpoint level].
44+
4145
4246== single & multi with result mapping
4347
@@ -57,3 +61,51 @@ and `multi`
5761----
5862ResponseEntity<Flux<String>>
5963----
64+
65+ Unfortunately if you need the reactive result to modify the http response, something like this:
66+
67+ [source, java]
68+ ----
69+ // does not work
70+ public ResponseEntity<Mono<Result>> someEndpoint() {
71+ return someBean.getResult()
72+ .map(r -> ResponseEntity
73+ .ok()
74+ .eTag(r.eTag())
75+ .body(Mono.just(r)));
76+ }
77+ ----
78+
79+ it will not work because the result type of the statement is `Mono<ResponseEntity<Mono<Result>>>` and not the expected `ResponseEntity<Mono<Result>>`.
80+
81+ This can be fixed by modifying the response type to
82+
83+ [source, yaml]
84+ ----
85+ openapi-processor-mapping: v6
86+
87+ options:
88+ # ...
89+
90+ map:
91+ # wrap the ResponseEntity with Mono
92+ result: reactor.core.publisher.Mono<org.springframework.http.ResponseEntity>
93+
94+ single: reactor.core.publisher.Mono
95+ multi: reactor.core.publisher.Flux
96+ ----
97+
98+ which will now generate the endpoint signature as
99+
100+ [source, java]
101+ ----
102+ public Mono<ResponseEntity<Mono<Result>>> someEndpoint() {
103+ // ...
104+ }
105+ ----
106+
107+ and the above code will now work.
108+
109+ It is recommended to configure this on the endpoint level if you just need this for a few endpoints.
110+
111+ See also Spring link:{spring-responseentity}[`ResponseEntity`] documentation.
0 commit comments