Skip to content

[REQ][JAVA][WebClient] Generate method that returns ResponseEntity #5599

@npeder

Description

@npeder

Is your feature request related to a problem? Please describe.

I would like to be able to see various HTTP information about the response, not just the object that was in the response body.

Describe the solution you'd like

If I generate with library resttemplate I get two methods: <operationName> and <operationName>WithHttpInfo. The first one just returns the object that was in the response body, but the last one returns a ResponseEntity. E.g.

    public String getName() throws RestClientException {
    public ResponseEntity<String> getNameWithHttpInfo() throws RestClientException {

I would like the same when generating with library webclient.
I would suggest changing the ApiClient invokeAPI method to return a WebClient.ResponseSpec, e.g.

    public <T> WebClient.ResponseSpec invokeAPI(String path, HttpMethod method, Map<String, Object> pathParams, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, String> cookieParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T> returnType) throws RestClientException {
        final WebClient.RequestBodySpec requestBuilder = prepareRequest(path, method, pathParams, queryParams, body, headerParams, cookieParams, formParams, accept, contentType, authNames);
        return requestBuilder.retrieve();
    }

And in the API you would return responseSpec.bodyToMono(returnType); in the Mono<String> getName() method and responseSpec.toEntity(returnType) in the Mono<ResponseEntity<String>> getNameWithHttpInfo()

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions