0
naeem76 created
- ABP Framework version: v7.1.0
- UI Type: MVC
- Database System: EF Core / MySQL
- Tiered (for MVC) or Auth Server Separated (for Angular): No
- Exception message and full stack trace:
- Steps to reproduce the issue:
Currently trying to describe enum models in Swagger, don't want to change the API parameters, they should still use and return integers, but the description should show which integer means what.
I've tried this
options.SchemaFilter<EnumSchemaFilter>();
public class EnumSchemaFilter : ISchemaFilter
{
public void Apply(OpenApiSchema schema, SchemaFilterContext context)
{
if (context.Type.IsEnum)
{
var array = new OpenApiArray();
array.AddRange(Enum.GetNames(context.Type).Select(n => new OpenApiString(n)));
// NSwag
schema.Extensions.Add("x-enumNames", array);
// Openapi-generator
schema.Extensions.Add("x-enum-varnames", array);
}
}
}
Also tried using the package Unchase.Swashbuckle.AspNetCore.Extensions
options.AddEnumsWithValuesFixFilters();
But results are the same, no change
Enum models are still
2 Answer(s)
-
1
-
0
That at least helped me steer in the right direction. Just learned that the order of that function matters, I had it at the end, we have a couple of other settings, but when I put it right after the line
options.CustomSchemaIds(type => type.FullName);
, it worked.Thank you!