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

Retrofit adapter: allow null response body for methods returning Unit #2625

Merged

Conversation

lukaszkalnik
Copy link
Contributor

@lukaszkalnik lukaszkalnik commented Jan 4, 2022

If the developer defined some service methods as returning Unit it means he's not interested in the response body. It will be mostly the case for responses like 204 No Content for which the server may return a null response body.

The current implementation will always throw an exception when null response body has been received, regardless of the expected return type defined by the developer.

This PR adds support for receiving null response body for methods defined like in the example below (note that the right type is defined as Unit):

@POST("/")
suspend fun postSomething(@Body something: String): Either<Error, Unit>

Copy link
Member

@nomisRev nomisRev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the great addition @lukaszkalnik!

Copy link
Member

@raulraja raulraja left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @lukaszkalnik !

@nomisRev nomisRev merged commit cbbf3e4 into arrow-kt:main Feb 17, 2022
@lukaszkalnik lukaszkalnik deleted the retrofit-adapter-allow-null-body-for-unit branch February 17, 2022 19:43
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.

None yet

4 participants