BottleRocketStudios / iOS-Hyperspace

An extremely lightweight wrapper around URLSession to make working with APIs a breeze.
Apache License 2.0
47 stars 17 forks source link

Decodable EmptyResponse #132

Closed br-nchiu closed 3 years ago

br-nchiu commented 3 years ago

Making EmptyResponse conform to Decodable to avoid branching logic between empty responses and JSON responses

CLAassistant commented 3 years ago

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

wmcginty commented 3 years ago

I believe the reason this is not marked as Decodable is because many projects have different requirements for an empty response. Some might mean 'any response' while other's might need a completely empty response. This seems like it would break that.

If you are using master, does EmptyDecodingStrategy solve your problem? There is a .default strategy which will take any response as a success, and a .validatedEmpty strategy which will ensure the response is empty before succeeding. More info here: https://github.com/BottleRocketStudios/iOS-Hyperspace/blob/master/Documentation/Guides/Handling%20Empty%20Responses.md (It's still in 'beta', so any feedback is appreciated)

BottleRocketBot commented 3 years ago
Warnings
:warning: No CHANGELOG entry added.

Generated by :no_entry_sign: Danger Swift against 6fcb7416efdef6ed937e388c5e6dd11fa9b10ece

codecov-io commented 3 years ago

Codecov Report

Merging #132 (6fcb741) into master (5025255) will not change coverage. The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #132   +/-   ##
=======================================
  Coverage   94.64%   94.64%           
=======================================
  Files          54       54           
  Lines        1680     1680           
=======================================
  Hits         1590     1590           
  Misses         90       90           
Impacted Files Coverage Δ
Sources/Hyperspace/Request/Request.swift 81.81% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 5025255...6fcb741. Read the comment docs.