|
@@ -1,9 +1,7 @@
|
|
|
-using Microsoft.OpenApi.Any;
|
|
|
-using Microsoft.OpenApi.Models;
|
|
|
+using Microsoft.OpenApi.Models;
|
|
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
|
|
using System;
|
|
|
using System.Linq;
|
|
|
-using System.Reflection;
|
|
|
using ZhonTai.Common.Extensions;
|
|
|
|
|
|
namespace ZhonTai.Admin.Core.Filters;
|
|
@@ -15,9 +13,10 @@ public class EnumSchemaFilter : ISchemaFilter
|
|
|
var type = context.Type;
|
|
|
if (type.IsEnum)
|
|
|
{
|
|
|
+ var enumValueType = type.GetField("value__").FieldType;
|
|
|
var items = Enum.GetValues(type).Cast<Enum>()
|
|
|
.Where(m => !m.ToString().Equals("Null")).Select(x =>
|
|
|
- $"{x.ToDescription()}={((int)type.InvokeMember(x.ToString(), BindingFlags.GetField, null, null, null))}").ToList();
|
|
|
+ $"{x.ToDescription()}={Convert.ChangeType(x, enumValueType)}").ToList();
|
|
|
|
|
|
if (items?.Count > 0)
|
|
|
{
|