updated list options and response validatore tested
This commit is contained in:
@@ -34,6 +34,7 @@ class ContextRetrievers:
|
||||
is_auth: bool = False
|
||||
is_event: bool = False
|
||||
key_: str = ""
|
||||
RESPONSE_VALIDATOR = None
|
||||
|
||||
def __init__(self, func):
|
||||
self.func = func
|
||||
@@ -105,10 +106,10 @@ class ListOptionsBase:
|
||||
query_options = QueryOptions(table=self.table, data=self.list_options, model_query=self.model_query)
|
||||
return db_session, query_options
|
||||
|
||||
def paginated_result(self, records) -> PaginationResult:
|
||||
def paginated_result(self, records, response_model: Optional[BaseModel] = None) -> PaginationResult:
|
||||
pagination = Pagination(data=records)
|
||||
if isinstance(self.list_options, dict):
|
||||
pagination.change(**self.list_options)
|
||||
elif isinstance(self.list_options, BaseModel):
|
||||
pagination.change(**self.list_options.model_dump())
|
||||
return PaginationResult(data=records, pagination=pagination)
|
||||
return PaginationResult(data=records, pagination=pagination, response_model=response_model)
|
||||
|
||||
Reference in New Issue
Block a user