[Java][Retrofit2] Return ResponseBody if response is "file"#6407
Merged
Conversation
Until now -------------------- If a swagger endpoint returned a file (e.g. an image), then the Retrofit2 template has choosen the return type java.io.File. However, retrofit cannot deal with this and throws a com.google.gson.stream.MalformedJsonException. New: ------------------- If a swagger endpoint returns a file, then the corresponding Retrofit2 endpoint will return a okhttp3.ResponseBody which can be used to retrieve the file.
Contributor
|
@craffael thanks for the PR. I wonder if you and rebase the change on the latest master to resolve the merge conflicts as we just merged another PR related to retrofit2 into master. |
Contributor
|
FYI. I've updated the petstore samples via 0f1a61d Next time please run |
Contributor
|
I need to roll back this change due to the following errors: |
wing328
added a commit
that referenced
this pull request
Sep 1, 2017
…6421) * Revert "Make the Rust codegen compile. (#6411)" This reverts commit 60766c6. * Revert "[Kotlin] Fix model enum generation (#6383)" This reverts commit adf5d64. * Revert "Global namespaces for ruby basic types (#6418)" This reverts commit 070894d. * Revert "add ehyche to swift tech comm" This reverts commit 5c62ba1. * Revert "[python-client] Thread pool fix (#6396)" This reverts commit a28ce0b. * Revert "update retrofit2 petstore samples" This reverts commit 0f1a61d. * Revert "Retrofit2: Return ResponseBody if response if file. (#6407)" This reverts commit 481c040.
Contributor
Author
|
Sorry about that. I don't know why I didn't find ./bin/java-petstore-retrofit2-all.sh. I think I was looking for something that started with java, but still is hould have found that. I will fix this now and resubmit. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Until now
If a swagger endpoint returned a file (e.g. an image), then the Retrofit2
template has choosen the return type java.io.File. However, retrofit cannot
deal with this and throws a com.google.gson.stream.MalformedJsonException.
New:
If a swagger endpoint returns a file, then the corresponding Retrofit2 endpoint
will return a okhttp3.ResponseBody which can be used to retrieve the file.
PR checklist
./bin/to update Petstore sample so that CIs can verify the change.There is no shell script for Retrofit2
3.0.0branch for breaking (non-backward compatible) changes.Description of the PR
See issue #6406