| 1 |
package uniontype |
| 2 |
|
| 3 |
|
| 4 |
type TopLevelUnion struct { |
| 5 |
Name string `json:"name"` |
| 6 |
|
| 7 |
Union `json:",inline"` |
| 8 |
} |
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
type Union struct { |
| 13 |
|
| 14 |
|
| 15 |
UnionType string `json:"unionType"` |
| 16 |
|
| 17 |
FieldA int `json:"fieldA,omitempty"` |
| 18 |
FieldB int `json:"fieldB,omitempty"` |
| 19 |
} |
| 20 |
|
| 21 |
|
| 22 |
type Union2 struct { |
| 23 |
|
| 24 |
Type string `json:"type"` |
| 25 |
|
| 26 |
Alpha int `json:"alpha,omitempty"` |
| 27 |
|
| 28 |
Beta int `json:"beta,omitempty"` |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
type InlinedUnion struct { |
| 33 |
Name string `json:"name"` |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
Field1 *int `json:"field1,omitempty"` |
| 38 |
|
| 39 |
|
| 40 |
Field2 *int `json:"field2,omitempty"` |
| 41 |
|
| 42 |
Union `json:",inline"` |
| 43 |
Union2 `json:",inline"` |
| 44 |
} |