netable icon indicating copy to clipboard operation
netable copied to clipboard

Revisit parameter encoding when Swift supports encode to dictionary

Open brendanlensink opened this issue 6 years ago • 3 comments

When encoding GET parameters, we're currently encoding the params to JSON, the decoding to [String: Any]. This is far from ideal but at the time seems like the simplest way.

If Swift does add support for encoding directly to Dictionary we should jump right on that.

brendanlensink avatar Nov 16 '18 17:11 brendanlensink

@brendanlensink Swift 5.6 includes https://github.com/apple/swift-evolution/blob/main/proposals/0320-codingkeyrepresentable.md

I am wondering if that's what we're looking for here?

sakuraehikaru avatar Aug 30 '22 21:08 sakuraehikaru

This is interesting, but AFAICT would only be available in iOS 15.4 and above. This is a little tricky, since I think it's unlikely any kind of backwards compatible solution will be introduced in the future.

I think we've got a feasible couple options right now:

  1. Do nothing. This hasn't really caused any problems yet, even though it's not ideal.
  2. Add support for CodingKeyRepresentable where available, leave the old solution in where it's not
  3. Drag our feet a little, eventually bump the minimum app version up and remove the old solution.

I'm sort of inclined to just go with option 1 for now, but we can probably keep this issue open for future consideration.

brendanlensink avatar Aug 30 '22 22:08 brendanlensink

Yeah option 3 sort of includes option 1, and the timing for option 3 is probably some time next year, when iOS 16 reaches 70% adoption rate. That could be a good time to implement CodingKeyRepresentable to be even safer, should no urgent needs arise by then.

sakuraehikaru avatar Aug 30 '22 22:08 sakuraehikaru