In AppHost.Configure
I set a global JSON config JsConfig.TreatEnumAsInteger = false;
and have a simple handler with two GET endpoints
public object Get(GetDayOfWeekAsText request)
{
return new GetDayOfWeekResponse();
}
public object Get(GetDayOfWeekAsInt request)
{
return new HttpResult(new GetDayOfWeekResponse())
{
ResultScope = () => JsConfig.With(new Config
{
TreatEnumAsInteger = true
})
};
}
Depending on the request I call first all subsequent requests will serialize enums as text or integer until the application is recycled. Explicitly setting TreatEnumAsInteger
in GetDayOfWeekAsText
has no effect.
Thanks!