From 5caabcf63b4e6e0de6f0f71a631ceb76a419a19e Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Mon, 18 Nov 2024 16:48:42 +0000 Subject: [PATCH] fix: Swift.DecodingError.keyNotFound when decoding Traits (#71) --- FlagsmithClient/Classes/Identity.swift | 2 +- FlagsmithClient/Classes/Trait.swift | 2 +- FlagsmithClient/Classes/Traits.swift | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/FlagsmithClient/Classes/Identity.swift b/FlagsmithClient/Classes/Identity.swift index 5e42bcb..933a1e7 100644 --- a/FlagsmithClient/Classes/Identity.swift +++ b/FlagsmithClient/Classes/Identity.swift @@ -20,5 +20,5 @@ public struct Identity: Decodable, Sendable { public let flags: [Flag] public let traits: [Trait] - public let transient: Bool + public let transient: Bool? } diff --git a/FlagsmithClient/Classes/Trait.swift b/FlagsmithClient/Classes/Trait.swift index 0ea78c1..d85a1de 100644 --- a/FlagsmithClient/Classes/Trait.swift +++ b/FlagsmithClient/Classes/Trait.swift @@ -26,7 +26,7 @@ public struct Trait: Codable, Sendable { /// - note: In the future, this can be renamed back to 'value' as major/feature-breaking /// updates are released. public var typedValue: TypedValue - public let transient: Bool + public let transient: Bool? /// The identity of the `Trait` when creating. internal let identifier: String? diff --git a/FlagsmithClient/Classes/Traits.swift b/FlagsmithClient/Classes/Traits.swift index 3103cc1..29667c9 100644 --- a/FlagsmithClient/Classes/Traits.swift +++ b/FlagsmithClient/Classes/Traits.swift @@ -14,7 +14,7 @@ public struct Traits: Codable, Sendable { public let traits: [Trait] public let identifier: String? public let flags: [Flag] - public let transient: Bool + public let transient: Bool? init(traits: [Trait], identifier: String?, flags: [Flag] = [], transient: Bool = false) { self.traits = traits @@ -30,3 +30,4 @@ public struct Traits: Codable, Sendable { try container.encode(transient, forKey: .transient) } } +