ResponseStreamEvent conforms to Codable, but the conformance is asymmetric:
init(from:) is custom — it decodes from the API's top-level type discriminator format.
encode(to:) is synthesized — it encodes using Swift enum case wrappers, which don't match the API payload shape.
This means encoding an event and decoding it back will fail, which can surprise callers who try to log, cache, or replay events via JSON.
Options:
- Implement a matching
encode(to:) that encodes the underlying event payloads in the original API shape.
- Drop
Encodable conformance and use Decodable only, if encoding isn't intended.
Flagged by Copilot review on #423.
ResponseStreamEventconforms toCodable, but the conformance is asymmetric:init(from:)is custom — it decodes from the API's top-leveltypediscriminator format.encode(to:)is synthesized — it encodes using Swift enum case wrappers, which don't match the API payload shape.This means encoding an event and decoding it back will fail, which can surprise callers who try to log, cache, or replay events via JSON.
Options:
encode(to:)that encodes the underlying event payloads in the original API shape.Encodableconformance and useDecodableonly, if encoding isn't intended.Flagged by Copilot review on #423.