Is there a way to display all enums as their string value in swagger instead of their int value?
I want to be able to submit POST actions and put enums according to
I have found nice workaround Here:
@PauloVetor - solved it using ShemaFilter like this:
public class EnumSchemaFilter : ISchemaFilter
{
public void Apply(OpenApiSchema model, SchemaFilterContext context)
{
if (context.Type.IsEnum)
{
model.Enum.Clear();
Enum.GetNames(context.Type)
.ToList()
.ForEach(n => model.Enum.Add(new OpenApiString(n)));
}
}
}
}
And in Startup.cs:
services.AddSwaggerGen(options =>
{
options.SchemaFilter();
}