[Question]: How to enumerate values a string can take on?
Closed this issue · 2 comments
RPGillespie6 commented
What are you wanting to achieve?
I have a string property on a POST body that can take on the values "cGy", "Gy", "%", or "cc"
I can't figure out a way to get swashbuckle to generate docs for that.
What code or approach do you have so far?
The closest I've come is using an enum and enabling enum strings setting:
public enum ConstraintUnit
{
Gy,
cGy,
Percent,
cc,
}
However, that required me to spell out "Percent" instead of using "%".
Is there a way I can just do:
[SwaggerEnum(["cGy", "Gy", "%", "cc"])]
public string unit {get; set}
or something like this?
Additional context
No response
martincostello commented
Which serializer are you using?
For example with Newtonsoft.JSON you can do something like this:
RPGillespie6 commented
Yes, brilliant, this is exactly what I was looking for, just was having a hard time find it. Thank you very much!