mirror of https://github.com/abpframework/abp.git
3 changed files with 32 additions and 1 deletions
@ -0,0 +1,23 @@ |
|||||
|
using Microsoft.OpenApi.Any; |
||||
|
using Microsoft.OpenApi.Models; |
||||
|
using Swashbuckle.AspNetCore.SwaggerGen; |
||||
|
using System; |
||||
|
using System.Linq; |
||||
|
|
||||
|
namespace Volo.Abp.Swashbuckle; |
||||
|
|
||||
|
public class AbpSwashbuckleEnumSchemaFilter : ISchemaFilter |
||||
|
{ |
||||
|
public void Apply(OpenApiSchema schema, SchemaFilterContext context) |
||||
|
{ |
||||
|
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…
Reference in new issue