I have a generic Form trait with a number of implementations. I would love to be able to specify the input as
.in(formBody[GenericFormTrait]), or even more ideally,
.in(oneOf[GenericFormTrait](oneOfVariant(formBody[FormA]), oneOfVariant(formBody[FormB])))) etc. but that doesn’t work.
Instead, I’ve set the input as
formBody[GenericFormTrait] and written a custom codec that decodes into the specific forms based on a discriminator. The problem is, the forms are pretty complex, so writing a function for each
Map<String, String> => Form is pretty gruesome. I was really hoping a mixture of Tapir oneOf + discriminators would make this kind of body possible without all the extra work?