CreateAPI icon indicating copy to clipboard operation
CreateAPI copied to clipboard

fix: Discriminator respects useSwiftyPropertyNames

Open AndrewSB opened this issue 10 months ago • 0 comments

JSON parsing for discriminators fails when the discriminator's propertyName has an _ in it, and the default value of swiftyPropertyNames is true

this fix uses the PropertyName processing to respect the options passed into the generator

in practice, a JSONDecoder with .keyDecodingStrategy = .convertFromSnakeCase set will fail to parse some_kind since it's looking for someKind instead.

this change will result in this being generated instead

             struct Discriminator: Decodable {
-                let some_kind: String
+                let someKind: String
             }

AndrewSB avatar Feb 18 '25 05:02 AndrewSB