This repository was archived by the owner on Apr 14, 2026. It is now read-only.
Commit e59435c
feat: add fixed properties and discriminator auto-set for union types
Complete the union type implementation to match the original oapi-codegen:
- Extract wrapper properties (type: object with properties alongside
oneOf/anyOf) into FixedFields on the union struct
- MarshalJSON merges fixed fields into union output; UnmarshalJSON
extracts them
- Auto-set discriminator value in From/Merge methods when all variants
are mapped (matching original gating behavior)
- Set on wrapper (t.Type) when discriminator is a fixed field
- Set on variant (v.Discriminator) when it lives on the variant schema
- Refactor generateOneOfType/generateAnyOfType into shared helper
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent b5a25d0 commit e59435c
4 files changed
Lines changed: 262 additions & 41 deletions
File tree
- experimental/codegen/internal
- test
- components/composition/output
- comprehensive/output
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1029 | 1029 | | |
1030 | 1030 | | |
1031 | 1031 | | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
1035 | 1040 | | |
1036 | 1041 | | |
1037 | 1042 | | |
1038 | 1043 | | |
1039 | 1044 | | |
1040 | 1045 | | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
1041 | 1052 | | |
1042 | 1053 | | |
1043 | 1054 | | |
1044 | | - | |
| 1055 | + | |
1045 | 1056 | | |
| 1057 | + | |
1046 | 1058 | | |
1047 | 1059 | | |
| 1060 | + | |
1048 | 1061 | | |
1049 | 1062 | | |
1050 | 1063 | | |
| |||
1063 | 1076 | | |
1064 | 1077 | | |
1065 | 1078 | | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
1066 | 1084 | | |
1067 | 1085 | | |
1068 | | - | |
1069 | | - | |
1070 | | - | |
1071 | | - | |
1072 | | - | |
1073 | | - | |
1074 | | - | |
1075 | | - | |
1076 | | - | |
1077 | | - | |
1078 | | - | |
1079 | | - | |
1080 | | - | |
1081 | | - | |
1082 | | - | |
1083 | | - | |
1084 | | - | |
1085 | | - | |
1086 | | - | |
1087 | | - | |
1088 | | - | |
1089 | | - | |
1090 | | - | |
1091 | | - | |
1092 | | - | |
1093 | | - | |
1094 | | - | |
1095 | | - | |
1096 | | - | |
1097 | | - | |
| 1086 | + | |
1098 | 1087 | | |
1099 | 1088 | | |
1100 | 1089 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
412 | 427 | | |
413 | | - | |
414 | | - | |
415 | | - | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
416 | 432 | | |
417 | | - | |
| 433 | + | |
418 | 434 | | |
419 | 435 | | |
420 | 436 | | |
421 | 437 | | |
422 | 438 | | |
423 | 439 | | |
424 | 440 | | |
425 | | - | |
| 441 | + | |
426 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
427 | 446 | | |
428 | | - | |
429 | 447 | | |
430 | 448 | | |
431 | 449 | | |
| |||
0 commit comments