I have model in open-api v.3 spec. I use openapi-generator-maven-plugin to generate java client for library webclient (spring 5 – webflux). I want to send back to client file and http headers. Generated code doesn’t have method to get response headers.
Generated code for client doesn’t contains code which provide access to response headers. For example if I use library resttemplate there is method public MultiValueMap getResponseHeaders() . Is there a way how to get response headers with library -webclient ?
template for resttemplate library contains this: private MultiValueMap responseHeaders; link: github
code for webclient is here: github
Advertisement
Answer
OpenAPI generator was extended since 5.2 and now the webclient library has two methods for each endpoint one with suffix WithHttpInfo
and with a return type Mono<ResponseEntity<T>>
. See PR #9327. So if you have for example an endpoint getUser
it generates:
Mono<UserDTO> getUser(); Mono<ResponseEntity<UserDTO>> getUserWithHttpInfo();
Then you can call a method with WithHttpInfo
which returns ResponseEntity
and call ResponseEntity#getHeaders
getUserWithHttpInfo().getHeaders()