Skip to content

Add status code and response headers of the last request to java and c# #1127

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

Merged
merged 1 commit into from
Aug 26, 2015
Merged

Add status code and response headers of the last request to java and c# #1127

merged 1 commit into from
Aug 26, 2015

Conversation

ivanmartinvalle
Copy link
Contributor

Per #990

I would like to add the ability to return the status code and response headers from the previous API call from java and csharp. The python client already provides this ability via the last_response variable. This is necessary for our API, as we need the value of the Location header after a POST request.

Approach: Before returning the response body, set the non-body parts of the response on ApiClient.

@ivanmartinvalle
Copy link
Contributor Author

@wing328 I would like to get your suggestion merged, but it appears that there is a failure on one of the scala tests. It happens with and without my changes locally (and they definitely don't look related). Any insight as to what I can do to move forward?

@fehguy
Copy link
Contributor

fehguy commented Aug 25, 2015

@ivanmartinvalle I'm seeing the tests pass via travis-ci. Can you run off a clean master branch? What is the error you're getting?

@ivanmartinvalle
Copy link
Contributor Author

@fehguy the last commit before mine is "Merge pull request #1123 from wing328/python_typo".

The error is in swagger-scala-client
Tests in error:
UserApi should fetch a user(UserApiTest): 12 was not equal to 1

@wing328
Copy link
Contributor

wing328 commented Aug 25, 2015

@ivanmartinvalle my commit (#1123) does not change the Scala client. Let me look into that as I suspect it's due to data change in the server side (petstore server)

@wing328
Copy link
Contributor

wing328 commented Aug 25, 2015

@ivanmartinvalle the user record looks good:

{
  "id": 1,
  "username": "user1",
  "firstName": "first name 1",
  "lastName": "last name 1",
  "email": "[email protected]",
  "password": "XXXXXXXXXXX",
  "phone": "123-456-7890",
  "userStatus": 1
}

let me reopen this PR to trigger the test again and see if the error persists.

@wing328 wing328 closed this Aug 25, 2015
@wing328 wing328 reopened this Aug 25, 2015
@wing328
Copy link
Contributor

wing328 commented Aug 25, 2015

@ivanmartinvalle now the tests passed.

@wing328
Copy link
Contributor

wing328 commented Aug 26, 2015

@ivanmartinvalle thanks for the PR to add status and response header to API client of Java and C#.

Testing looks good.

wing328 added a commit that referenced this pull request Aug 26, 2015
Add status code and response headers of the last request to java and c#
@wing328 wing328 merged commit b35a7b6 into swagger-api:master Aug 26, 2015
@fehguy fehguy modified the milestone: v2.1.4 Oct 26, 2015
stevedenman added a commit to stevedenman/swagger-codegen that referenced this pull request Sep 9, 2016
Apply same workaround as swagger-api#1127 to typescript-angular2 template.
@wing328
Copy link
Contributor

wing328 commented Sep 9, 2016

UPDATE: we've replaced this approach (varaibles to store the last status code and response headers) with an additional method WithHttpInfo, e.g. https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/java/okhttp-gson/src/main/java/io/swagger/client/api/PetApi.java#L123-L137

wing328 pushed a commit that referenced this pull request Sep 12, 2016
* Add last response code and headers

Apply same workaround as #1127 to typescript-angular2 template.

* Add WithHttpInfo() methods to return raw response.

* Revert change to http method formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants