Details
Serialize Enum as String
Return enums as their string value
builder.Services.AddControllers()
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
});
Or you could just annotate the property like so
public class ApplicationUser
{
...
[JsonConverter(typeof(JsonStringEnumConverter))]
public Gender Gender { get; set; }
...
}
Enums are still saved as their integer representation in the database.