bauerji / flask-pydantic

flask extension for integration with the awesome pydantic package
MIT License
352 stars 56 forks source link

Aliased list query parameters do not work #59

Open janikarki opened 1 year ago

janikarki commented 1 year ago
flask-pydantic==0.10.0
flask==2.1.2

Steps to reproduce

  1. 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
  2. Set this as query: QueryModel in your request handler function signature.
  3. Send a request with ?order-by=name

Expected result

Actual result

{
  "validation_error": {
    "query_params": [
      {
        "loc": [
          "order-by"
        ], 
        "msg": "value is not a valid list", 
        "type": "type_error.list"
      }
    ]
  }
}

In short: