Maillol / aiohttp-pydantic

Aiohttp View that validates request body and query sting regarding the annotations declared in the View method
MIT License
67 stars 21 forks source link

It would be nice to be able to use an input model for GET requests too. #14

Closed jalelegenda closed 3 years ago

jalelegenda commented 3 years ago

This is a feature request, but it'd be nice to be able to use an input model as opposed to e.g. 10 parameters for GET requests.

Maillol commented 3 years ago

In order to group parameters like this ?

>>> class Pagination(GroupParameters):
...     page: int = 0
...     nb_elements_per_pages: int = 10
... 

class ArticleView(PydanticView):
    async def get(self, pagination: Pagination):
        return web.json_response({'with_comments': with_comments})
Maillol commented 3 years ago

Added in aiohttp-pydantic v1.12.0

https://github.com/Maillol/aiohttp-pydantic#group-parameters