Enum attribute for SwaggerSchema #3167
Unanswered
alexministrybrands
asked this question in
Q&A
Replies: 1 comment
-
You could create your own custom attribute, and then use a filter to change the schema. I don't think this is something we'd want to build in, because the "obvious" solution is to just use an Enum. If you don't want to do that, then that's a custom scenario. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello. I'm using Swashbuckle for one of my API projects and want to handle requests with string enum fields. I don't want to use Enum object for a request property, because it requires additional logic here for json conversion and additional logic for validation. Also, the shape of the error looks weird for me in case when json cannot convert the provided string to Enum class value.
What I would expect from Swashbuckle is a possibility to use SwaggerSchema on request string property, but tell that it has to be an enum. So something like that:
so that my openapi.yaml file would look like this for that request:
Could you let me know if I can somehow achieve that?
Beta Was this translation helpful? Give feedback.
All reactions