-
-
Notifications
You must be signed in to change notification settings - Fork 8.5k
Closed
Labels
Description
I want the user to be able to select parameter values from an enum list of values as a dropdown in the swagger documentation.
The only way, to my knowledge, to do that is to create a Enum pydantic class, and designate a parameter as a part of that class. Which is fine. But in my situation, I want the enum to be dynamically generated based on all unique document values of a property stored in a MongoDB collection. I think you can create a BaseModel class dynamically using the create_model() function, but as far as I know that's not possible with a Enum class.
So my question is: How can I create a parameter enumeration in Swagger from all values in a mongDb collection?