-
Hi, I tried this without success: class Enum(str, Enum):
nom = "nom"
prenom ="prenom"
commune = "commune"
class Query(BaseModel):
column: Enum = Enum.nom
@utils.route('/distinct/<string:column>', methods=["GET"])
@spectree_api.validate(query=Query, resp=Response("HTTP_403", HTTP_200=DistinctResp), tags=["Utils"])
def get_distinct(column):
.... This adds a new query parameter to the request description in the swagger file. In my case this is not what I was aiming for: the "column" variable should be a path parameter. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
You almost got it. As you mentioned, flask URL variables doesn't support Enum. But you can use Enum in the URL query. class Enum(str, Enum):
nom = "nom"
prenom ="prenom"
commune = "commune"
class Query(BaseModel):
column: Enum = Enum.nom
@utils.route('/distinct', methods=["GET"])
@spectree_api.validate(query=Query, resp=Response("HTTP_403", HTTP_200=DistinctResp), tags=["Utils"])
def get_distinct(column):
.... Try to query this service with |
Beta Was this translation helpful? Give feedback.
You almost got it. As you mentioned, flask URL variables doesn't support Enum. But you can use Enum in the URL query.
Try to query this service with
http :8000/distinct?column=nom