maliming
2 years ago
No known key found for this signature in database
GPG Key ID: A646B9CB645ECEA4
1 changed files with
22 additions and
2 deletions
-
framework/src/Volo.Abp.Swashbuckle/Microsoft/Extensions/DependencyInjection/AbpSwaggerGenOptionsExtensions.cs
|
|
|
@ -1,4 +1,6 @@ |
|
|
|
using Swashbuckle.AspNetCore.SwaggerGen; |
|
|
|
using System; |
|
|
|
using System.Linq; |
|
|
|
using Swashbuckle.AspNetCore.SwaggerGen; |
|
|
|
using Volo.Abp.Swashbuckle; |
|
|
|
|
|
|
|
namespace Microsoft.Extensions.DependencyInjection; |
|
|
|
@ -14,4 +16,22 @@ public static class AbpSwaggerGenOptionsExtensions |
|
|
|
{ |
|
|
|
swaggerGenOptions.SchemaFilter<AbpSwashbuckleEnumSchemaFilter>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public static void CustomAbpSchemaIds(this SwaggerGenOptions options) |
|
|
|
{ |
|
|
|
string SchemaIdSelector(Type modelType) |
|
|
|
{ |
|
|
|
if (!modelType.IsConstructedGenericType) |
|
|
|
{ |
|
|
|
return modelType.FullName!.Replace("[]", "Array"); |
|
|
|
} |
|
|
|
|
|
|
|
var prefix = modelType.GetGenericArguments() |
|
|
|
.Select(SchemaIdSelector) |
|
|
|
.Aggregate((previous, current) => previous + current); |
|
|
|
return modelType.FullName!.Split('`').First() + "Of" + prefix; |
|
|
|
} |
|
|
|
|
|
|
|
options.CustomSchemaIds(SchemaIdSelector); |
|
|
|
} |
|
|
|
} |
|
|
|
|