Example returns a random example value.
(r *ExampleGenerator)
| 649 | |
| 650 | // Example returns a random example value. |
| 651 | func (u *Union) Example(r *ExampleGenerator) any { |
| 652 | if len(u.Values) == 0 { |
| 653 | return nil |
| 654 | } |
| 655 | return u.Values[r.Int()%len(u.Values)].Attribute.Example(r) |
| 656 | } |
| 657 | |
| 658 | // GetTypeKey returns the discriminator field name for JSON marshaling. |
| 659 | // Defaults to "type" if not explicitly set via Meta("oneof:type:field"). |