Closed
Description
When setting custom serialization settings on JsonApiOptions
, they are not used. In our scenario we have a few enums exposed as attributes and we want them to serialize into their text representation instead of numeric.
Example:
public enum ScreenOrientation
{
Horizontal, Vertical
}
public class DemoResource : Identifyable
{
[Attr]
public ScreenOrientation Orientation { get; set; }
}
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddJsonApi<AppDbContext>(options =>
{
options.SerializerSettings.Converters = new List<JsonConverter>
{
new StringEnumConverter()
};
});
}
}
Putting [JsonConverter(typeof(StringEnumConverter))]
on ScreenOrientation works, but the global setting does not.
Using the global setting should work, according to https://github.com/json-api-dotnet/JsonApiDotNetCore/blob/master/docs/usage/options.md#custom-serializer-settings.
Metadata
Metadata
Assignees
Labels
No labels