Swagger UI Web Api documentation Present enums as strings?

后端 未结 20 2059
半阙折子戏
半阙折子戏 2020-11-27 11:31

Is there a way to display all enums as their string value in swagger instead of their int value?

I want to be able to submit POST actions and put enums according to

20条回答
  •  我在风中等你
    2020-11-27 11:44

    .Net Core 3.0

       using Newtonsoft.Json.Converters;
    
     services
        .AddMvc(options =>
        {
         options.EnableEndpointRouting = false;
         })
        .AddNewtonsoftJson(options => options.SerializerSettings.Converters.Add(new StringEnumConverter()))
    

提交回复
热议问题