Merge pull request #254 from gkLeo/EnableDescriptionOfEnumForSwagger

Enable description of enum in swagger
This commit is contained in:
ansonzhang 2022-03-11 14:26:09 +08:00 committed by GitHub
commit 46e7967d8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 1 deletions

View File

@ -18,6 +18,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using System.IdentityModel.Tokens.Jwt;
using System.Reflection;
@ -126,6 +127,8 @@ namespace Blog.Core
//options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
//设置本地时间而非UTC时间
options.SerializerSettings.DateTimeZoneHandling = DateTimeZoneHandling.Local;
//添加Enum转string
options.SerializerSettings.Converters.Add(new StringEnumConverter());
});
services.Replace(ServiceDescriptor.Transient<IControllerActivator, ServiceBasedControllerActivator>());

View File

@ -28,6 +28,7 @@
<PackageReference Include="nacos-sdk-csharp-unofficial.Extensions.Configuration" Version="0.8.5" />
<PackageReference Include="nacos-sdk-csharp-unofficial.IniParser" Version="0.8.5" />
<PackageReference Include="nacos-sdk-csharp.AspNetCore" Version="1.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.6.3" />
</ItemGroup>
<ItemGroup>

View File

@ -45,7 +45,7 @@ namespace Blog.Core.Extensions
c.OrderActionsBy(o => o.RelativePath);
});
c.UseInlineDefinitionsForEnums();
try
{
//这个就是刚刚配置的xml文件名
@ -106,6 +106,7 @@ namespace Blog.Core.Extensions
});
services.AddSwaggerGenNewtonsoftSupport();
}
}