Repository navigation
Commit 11221eb
[kotlin] fix: enumUnknownDefaultCase's moshi fallback adapters break nullable enum fields (#24894)
* [kotlin] fix: make the enumUnknownDefaultCase moshi fallback adapters null-safe
SerializerHelper registers a moshi EnumJsonAdapter with withUnknownFallback
per enum, but EnumJsonAdapter is not null-safe and it is registered bare:
any model with a nullable enum property throws "value was null! Wrap in
.nullSafe() to write nullable values" on a null value, reading and writing
alike. The flag traded unknown-value tolerance for a regression on every
optional enum field. Append .nullSafe() in both branches.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GcwZ1arjLZNpetHz2a3TJz
* test: [kotlin] shorten the null-safe adapter test comment
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 7bee48f commit 11221eb
3 files changed
Lines changed: 34 additions & 7 deletions
File tree
- modules/openapi-generator/src
- main/resources/kotlin-client/jvm-common/infrastructure
- test/java/org/openapitools/codegen/kotlin
- samples/client/petstore/kotlin-enum-default-value/src/main/kotlin/org/openapitools/client/infrastructure
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
| 36 | + | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
990 | 990 | | |
991 | 991 | | |
992 | 992 | | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
993 | 1020 | | |
994 | 1021 | | |
995 | 1022 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
19 | 19 | | |
20 | 20 | | |
0 commit comments