Open janikarki opened 1 year ago
flask-pydantic==0.10.0 flask==2.1.2
Define a query model with an aliased list field.
class QueryModel(BaseModel): order_by: Optional[ List[Literal["created", "name"]] ] = Field(..., alias="order-by") class Config: allow_population_by_field_name = True
query: QueryModel
?order-by=name
query.order_by
['name']
{ "validation_error": { "query_params": [ { "loc": [ "order-by" ], "msg": "value is not a valid list", "type": "type_error.list" } ] } }
In short:
?order_by=name&order_by=created
Steps to reproduce
Define a query model with an aliased list field.
query: QueryModel
in your request handler function signature.?order-by=name
Expected result
query.order_by
should be a list['name']
.Actual result
In short:
?order_by=name&order_by=created
gives you list with these values).