We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b2a6a8 commit aafe117Copy full SHA for aafe117
ninja_extra/schemas/response.py
@@ -3,6 +3,7 @@
3
4
from ninja import Schema
5
from ninja.constants import NOT_SET
6
+from pydantic import validator
7
from pydantic.generics import GenericModel
8
from pydantic.main import BaseModel
9
from pydantic.networks import AnyHttpUrl
@@ -86,6 +87,12 @@ class NinjaPaginationResponseSchema(
86
87
):
88
items: List[T]
89
90
+ @validator("items", pre=True)
91
+ def validate_items(cls, value: Any) -> Any:
92
+ if value and not isinstance(value, list):
93
+ return list(value)
94
+ return value
95
+
96
NinjaPaginationResponseSchema.__generic_model__ = NinjaPaginationResponseSchema
97
98
class IdSchema(GenericModel, Generic[T], Schema):
0 commit comments