class BiDiGenerate::Schema

def union_params(type, ref = nil)

null-vs-absent — so no nullable allowlist is needed.
kwargs to the matching variant via `Union.build`, whose typed `as_json` handles
variant-specific fields become optional. The command body dispatches these
signature. A field is only required when every variant declares it required;
Merge a union's record variants into one flat param list for the command
def union_params(type, ref = nil)
  variants = type['variants'].map { |variant_ref| @types[variant_ref] }
  return nil unless variants.all? { |v| v && v['kind'] == 'record' }
  selector = type['selector']
  guard_union_dispatch_keys_simple!(selector, ref)
  params = merged_params(variants.map { |v| v['fields'] })
  annotate_discriminator_enum!(params, selector)
  params
end