Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger CodeGen APIClient.java not returning the headers from the rest response by calling resttemplate #9685

Closed
ghost opened this issue Aug 30, 2019 · 1 comment · Fixed by #9737

Comments

@ghost
Copy link

ghost commented Aug 30, 2019

Description

Swagger CodeGen APIClient.java not returning the headers from the rest response by calling resttemplate
It is returning only the response body. Please have a look into this.

Swagger-codegen version

2.4.5

Swagger declaration file content or url

addHeadersToRequest(headerParams, requestBuilder);
addHeadersToRequest(defaultHeaders, requestBuilder);

    RequestEntity<Object> requestEntity = requestBuilder.body(selectBody(body, formParams, contentType));

    ResponseEntity<T> responseEntity = restTemplate.exchange(requestEntity, returnType);
    
    statusCode = responseEntity.getStatusCode();
    responseHeaders = responseEntity.getHeaders();

    if (responseEntity.getStatusCode() == HttpStatus.NO_CONTENT) {
        return null;
    } else if (responseEntity.getStatusCode().is2xxSuccessful()) {
        if (returnType == null) {
            return null;
        }
        return responseEntity.getBody();
@thomasJoei
Copy link
Contributor

thomasJoei commented Sep 28, 2019

Created a PR for this fix.
#9737

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant