Skip to content

Fix IsStringEnumArray for nullable enum arrays#1904

Merged
lahma merged 1 commit intoRicoSuter:masterfrom
lahma:fix/nullable-enum-array-1660
Mar 8, 2026
Merged

Fix IsStringEnumArray for nullable enum arrays#1904
lahma merged 1 commit intoRicoSuter:masterfrom
lahma:fix/nullable-enum-array-1660

Conversation

@lahma
Copy link
Copy Markdown
Collaborator

@lahma lahma commented Mar 8, 2026

Summary

  • Fixes Array of nullable enums has IsStringEnumArray set to false (C#) #1660
  • IsStringEnumArray returned false for List<MyEnum?> because .Item.ActualSchema doesn't resolve through nullable oneOf wrappers
  • Changed to use .Item.ActualTypeSchema (2 occurrences), which filters out the null entry in oneOf wrappers — matching the existing pattern used by IsStringEnum

Test plan

  • Added test When_nullable_enum_array_then_IsStringEnumArray_is_true with a JSON schema containing a nullable enum array (oneOf: [null, $ref enum] in items)
  • Verified generated C# includes StringEnumConverter
  • All existing codegen tests pass (215 passed, 0 failed)

🤖 Generated with Claude Code

Use ActualTypeSchema instead of ActualSchema when resolving array item
schema, so that nullable oneOf wrappers are properly resolved to the
underlying enum type. This matches the existing pattern used by
IsStringEnum.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lahma lahma force-pushed the fix/nullable-enum-array-1660 branch from ca7aa01 to 2183c15 Compare March 8, 2026 17:59
@lahma lahma merged commit b640b56 into RicoSuter:master Mar 8, 2026
2 checks passed
@lahma lahma deleted the fix/nullable-enum-array-1660 branch March 8, 2026 18:44
This was referenced Apr 8, 2026
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.

Array of nullable enums has IsStringEnumArray set to false (C#)

1 participant