I'm writing a web api in .Net Core 2.2. I have an enumeration as follows:
using System.Runtime.Serialization;
namespace MyNamespace
{
public enum MyEnum
{
[EnumMember(Value = "Some Value")]
SomeValue
}
}
If I pass in random data as MyEnum in a request using the enum I rightly get an error, but if I pass "Some Value" or "SomeValue" it passes. How do I make "SomeValue" invalid? "SomeValue" isn't in my swagger and isn't a value I want to accept.
So basically, model validation passes for "SomeValue" when that isn't really valid.
Any ideas how I can make only "Some Value" valid? Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…