Skip to content
Rico Suter edited this page Feb 13, 2018 · 26 revisions

The enums in JSON Schema are only used to validate JSON data. This is why you can only define the enum values but not their names. NJsonSchema adds the x-enumNames property to the schema so that the enum value names are also available to the consumer. These names are required to generate meaningful code (CSharp or TypeScript).

Also see Integer vs String enumerations

Globally enable string enum serialization in ASP.NET Core

public void ConfigureServices(IServiceCollection services)
{
    services.AddMvc()
        .AddJsonOptions(options => 
            options.SerializerSettings.Converters.Add(new StringEnumConverter()));
Clone this wiki locally