Browse Source

Solving unit test error

pull/17042/head
masoodkhoshgard 3 years ago
parent
commit
26e23e8c03
  1. 2
      framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/Json/MvcCoreBuilderExtensions.cs
  2. 16
      framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleDocumentFilter.cs
  3. 2
      framework/src/Volo.Abp.Swashbuckle/Volo/Abp/Swashbuckle/AbpSwashbuckleEnumSchemaFilter.cs

2
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());

16
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<OpenApiSchema> properties = schema.Properties?.Values;
if (properties != null)
{
foreach (OpenApiSchema property in properties)
{
List<object> propertyEnums = property.Enum?.Cast<object>().ToList();
if (propertyEnums != null && propertyEnums.Any())
{
property.Description += "<br><br><strong>Possible values:</strong><br>" + string.Join("<br>", propertyEnums);
}
}
}
}
}
protected virtual string? RemoveRouteParameterConstraints(ActionDescriptor actionDescriptor)

2
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}")));

Loading…
Cancel
Save