System.Text.Json in ASP.NET APIs expect the discriminator key of a union to be passed as the first parameter in the JSON for optimization reasons. Currently, freezed generated classes have the unionKey placed as the last property which is then picked up by json converter last as can be seen in the toJson generated files:
I would like to have an option ( or even better be the default ) to have the generated unionKey be the first parameter. An alternative I am using now is opting out of using the unionKey and writing custom toJson methods