Skip to content

Retrofit template: return body string directly when failed to parse response body as JSON #1032

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 3 commits into from
Jul 30, 2015

Conversation

xhh
Copy link
Contributor

@xhh xhh commented Jul 29, 2015

When the deserialization fails due to JsonParseException and the expected type is String, then just return the body string.

This PR also fixes the unit test of UserApi#loginUser, which throws exception:
retrofit.converter.ConversionException: com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 9 path $
See the comment of the Retrofit template's author here

when failed to parse response body as JSON, fixing unit test for
UserApi#loginUser
@xhh
Copy link
Contributor Author

xhh commented Jul 29, 2015

integration test is good

Concurrency config is parallel='methods', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false
Running io.swagger.petstore.test.PetApiTest
Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 25.702 sec
Concurrency config is parallel='methods', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false
Running io.swagger.petstore.test.StoreApiTest
Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.015 sec
Concurrency config is parallel='methods', perCoreThreadCount=true, threadCount=2, useUnlimitedThreads=false
Running io.swagger.petstore.test.UserApiTest
Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 6.215 sec

Results :

Tests run: 15, Failures: 0, Errors: 0, Skipped: 0

wing328 added a commit that referenced this pull request Jul 30, 2015
Retrofit template: return body string directly when failed to parse response body as JSON
@wing328 wing328 merged commit cc358cf into swagger-api:develop_2.0 Jul 30, 2015
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.

2 participants