Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #5599
Closed
Open
Issue created Mar 16, 2020 by Administrator@rootContributor

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

Created by: 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

Assignee
Assign to
Time tracking