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

RFC: Runtime Root Key Decoding #41

Closed wmcginty closed 6 years ago

wmcginty commented 6 years ago

This provides an implementation for being able to being decoding a JSON blob at an arbitrary String 'rootKey'. We currently have similar functionality using the DecodableContainerType, but this involves the generation of a type for each possible key, and so is enforced at compile time.

This method (I have kept DecodableContainerType available in the interface) sacrifices some run time performance for the ability to provide that String at runtime.

While the current implementation accept only a single String parameter, the same logic could be applied to an array of Strings at the cost of additional performance.

codecov-io commented 6 years ago

Codecov Report

Merging #41 into release/2.0.0 will increase coverage by 0.44%. The diff coverage is 98.33%.

Impacted file tree graph

@@                Coverage Diff                @@
##           release/2.0.0      #41      +/-   ##
=================================================
+ Coverage          95.82%   96.26%   +0.44%     
=================================================
  Files                 26       28       +2     
  Lines                814      991     +177     
=================================================
+ Hits                 780      954     +174     
- Misses                34       37       +3
Impacted Files Coverage Δ
...Request/AnyNetworkRequest+DecodableContainer.swift 100% <100%> (ø) :arrow_up:
Tests/Helper/Mocks/MockDecodableContainer.swift 100% <100%> (ø)
Sources/Hyperspace/Request/AnyDecodable.swift 97.91% <97.91%> (ø)
Tests/DecodingTests.swift 94.56% <98.19%> (+5.09%) :arrow_up:

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 01f2026...48d9460. Read the comment docs.

wmcginty commented 6 years ago

Typos fixed and requests are now asserting on specific DecodingErrors.