Maillol / aiohttp-pydantic

Aiohttp View that validates request body and query sting regarding the annotations declared in the View method

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Optional query params with None not working

tuenut opened this issue · comments

Hello! I have code like below:

class PaginationParams(Group):
    page: Optional[int] = 1
    page_size: Optional[int] = 100

class MyApiView(PydanticView):
    async def get(self, pagination: PaginationParams):
        ...

And it works perfectly, but if I change the default values to None, the view responds with validation error details in the response:

[{"type": "missing", "loc": ["page"], "msg": "Field required", "input": {}, "in": "query string"}, {"type": "missing", "loc": ["page_size"], "msg": "Field required", "input": {}, "in": "query string"}]

For pagination parameters, it is not critical, but for filter parameters, it may be necessary.

Thanks for the bug report. It's fixed