I am using ServiceStack.Text to deserialize json received in rest api calls to objects C#. The model classes I use have defined the string representation using EnumMember attrib
I found out why my deserialization was not working. ServiceStack.Text was not interpreting the EnumMember attributes because enum declaration does not have DataContract attribute set. This is actually explained in the EnumMember documentation link I also linked in the question:
One way to use enumeration types in the data contract model is to apply the DataContractAttribute attribute to the type. You must then apply the EnumMemberAttribute attribute to each member that must be included in the data contract.
Expected results were produced by adding the missing attribute:
[DataContract] // This was missing
enum TestEnum
{
// ...
}