From 26e23e8c037c8716ef7db4c2f3b9a08639eb3200 Mon Sep 17 00:00:00 2001 From: masoodkhoshgard Date: Mon, 17 Jul 2023 14:49:25 +0330 Subject: [PATCH] Solving unit test error --- .../Mvc/Json/MvcCoreBuilderExtensions.cs | 2 -- .../Swashbuckle/AbpSwashbuckleDocumentFilter.cs | 16 ---------------- .../AbpSwashbuckleEnumSchemaFilter.cs | 2 ++ 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs index b6d17d77b2..8c6edd2eb0 100644 --- a/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs +++ b/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs @@ -1,6 +1,5 @@ using System; using System.Text.Json; -using System.Text.Json.Serialization; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; @@ -20,7 +19,6 @@ public static class MvcCoreBuilderExtensions options.JsonSerializerOptions.AllowTrailingCommas = true; options.JsonSerializerOptions.Converters.Add(new AbpStringToEnumFactory()); - options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter()); options.JsonSerializerOptions.Converters.Add(new AbpStringToBooleanConverter()); options.JsonSerializerOptions.Converters.Add(new AbpStringToGuidConverter()); options.JsonSerializerOptions.Converters.Add(new AbpNullableStringToGuidConverter()); diff --git a/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs b/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs index 162b872d03..d35443f98b 100644 --- a/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs +++ b/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs @@ -28,22 +28,6 @@ public class AbpSwashbuckleDocumentFilter : IDocumentFilter swaggerDoc .Paths .RemoveAll(path => !actionUrls.Contains(path.Key)); - - foreach (OpenApiSchema schema in swaggerDoc.Components.Schemas.Values) - { - ICollection properties = schema.Properties?.Values; - if (properties != null) - { - foreach (OpenApiSchema property in properties) - { - List propertyEnums = property.Enum?.Cast().ToList(); - if (propertyEnums != null && propertyEnums.Any()) - { - property.Description += "

Possible values:
" + string.Join("
", propertyEnums); - } - } - } - } } protected virtual string? RemoveRouteParameterConstraints(ActionDescriptor actionDescriptor) diff --git a/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleEnumSchemaFilter.cs b/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleEnumSchemaFilter.cs index 28f243aa9f..f637fb005e 100644 --- a/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleEnumSchemaFilter.cs +++ b/framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleEnumSchemaFilter.cs @@ -13,6 +13,8 @@ public class AbpSwashbuckleEnumSchemaFilter : ISchemaFilter if (context.Type.IsEnum) { schema.Enum.Clear(); + schema.Type = nameof(String); + schema.Format = nameof(String); Enum.GetNames(context.Type) .ToList() .ForEach(name => schema.Enum.Add(new OpenApiString($"{name}")));