-
Notifications
You must be signed in to change notification settings - Fork 27
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Description
There has been a PR (#63) that introduces the capability of returning ApiResult<Unit, ...> when a 204 occurs. This is generally fine if we expect that that is the only successful behavior.
But what if an endpoint can return a 200 with a specific body response, but can also return a 204 with no body? I'd like to open discussion and maybe ask for some guidance regarding this. I've also seen the README which kind of talks about 200 polymorphism but it again seems to only relate with errors. There's a few options to resolve this:
- Change
ApiResult<out T : Any, out E : Any>, so that at least T can be nullable. This would allow nullable responses, and fix this specific issue, but there may be reasons as to why you might not want to do this. - Allow some way to pass HTTP status code through Retrofit annotations in success responses. This way we could implement custom behavior in custom
Converter.Factorys. I tried this, and this is already possible in case of an error, but not in the case of success AFAIK. - I could try catch NPE, but that's not really a good solution
- I could use Response<MyDto?> and try to convert manually to ApiResult, but then I'd have to reimplement the whole CallAdapter logic.
Is there any other option? Thank you.
Requirements (place an x in each of the [ ])
- I've read and understood the Contributing guidelines and have done my best effort to follow them.
- I've read and agree to the Code of Conduct.
- I've searched for any related issues and avoided creating a duplicate issue.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request