Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aliased list query parameters do not work #59

Open
janikarki opened this issue Sep 20, 2022 · 0 comments · May be fixed by #63
Open

Aliased list query parameters do not work #59

janikarki opened this issue Sep 20, 2022 · 0 comments · May be fixed by #63

Comments

@janikarki
Copy link

janikarki commented Sep 20, 2022

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

Expected result

  • The request should be considered valid.
  • query.order_by should be a list ['name'].

Actual result

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

In short:

  • Aliased query params work.
  • List query params work (e.g. ?order_by=name&order_by=created gives you list with these values).
  • Aliased list query params do not work.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant