Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Comments

Close side panel

fix: Discriminator respects useSwiftyPropertyNames#216

Open
AndrewSB wants to merge 1 commit intoCreateAPI:mainCreateAPI/CreateAPI:mainfrom
AndrewSB:andrew/discriminator-respect-property-nameAndrewSB/CreateAPI:andrew/discriminator-respect-property-nameCopy head branch name to clipboard
Open

fix: Discriminator respects useSwiftyPropertyNames#216
AndrewSB wants to merge 1 commit intoCreateAPI:mainCreateAPI/CreateAPI:mainfrom
AndrewSB:andrew/discriminator-respect-property-nameAndrewSB/CreateAPI:andrew/discriminator-respect-property-nameCopy head branch name to clipboard

Conversation

@AndrewSB
Copy link

@AndrewSB AndrewSB commented Feb 18, 2025

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
             }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.