-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
Backport the autoTypeSafeEnumToJsonString and autoUnionToJsonObject options to avoid the nasty surprised the default impl causes when (not if!) people fall into the default rendering trap for things lke:
a) TypeSafeEnums e.g. type ProductId = ProductA | ProductB (where you just want "ProductA", as the TypeSafeEnumconverter would do if applied explicitly)
b) Unions that should render as a JSON object (record)
type UnionThatShouldBeAnObject =
| SimpleProduct of master: ProductId
| PairedProduct of {| primary: ProductId; backup: ProductId |}
will render as { "Case": "PairedProduct", "primary": "ProductA", "backup": "ProductA"} or { "Case": "PairedProduct", "master": "ProductA"}, as it would if you applied the UnionConverter explicitly
#96 is a very important related safety feature too
i.e.prevent:
"items": [
{
"serviceId": "5c8795be52e34e82883d61babed19513",
"serviceKind": {
"Case": "ProductA"
}
},
{
"serviceId": "8a55ebbf0d404485b50da95bdb53f7b3",
"serviceKind": {
"Case": "ProductB"
}
}
]
},
and default to
"items": [
{
"serviceId": "5c8795be52e34e82883d61babed19513",
"serviceKind": "ProductB"
},
{
"serviceId": "8a55ebbf0d404485b50da95bdb53f7b3",
"serviceKind": "ProductA"
}
]
Metadata
Metadata
Assignees
Labels
No labels