OpenAI icon indicating copy to clipboard operation
OpenAI copied to clipboard

Codable > Encodable | Decodable

Open kalafus opened this issue 1 year ago • 3 comments

What

be specific with Codable: use Encodable for queries, Decodable for results, instead of Codable for everything

Why

accurate inheritance prevents accidental misuse

Affected Areas

JSON encoding and decoding during networking

NOTE

I don't know what to do with the .stub() functions, which require that Responses are Encodable for testing purposes, when Responses should only have to be Decodable.

kalafus avatar Feb 07 '24 18:02 kalafus

Hey, @kalafus, thanks for your contribution! ✨ You're absolutely right about:

accurate inheritance prevents accidental misuse

It seems like tests here require some fixing now too 🙏🏼

ingvarus-bc avatar Feb 14 '24 14:02 ingvarus-bc

had to add a surprising amount of code due to an error that extensions for the Encodable protocol won't automatically implement this way... but it's done. have any ideas to de-duplicate? there's got to be a better way!

kalafus avatar Feb 15 '24 03:02 kalafus

Quality Gate Passed Quality Gate passed

Issues
0 New issues

Measures
0 Security Hotspots
No data about Coverage
1.9% Duplication on New Code

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Feb 16 '24 02:02 sonarqubecloud[bot]