CustomPageableResponse
The CustomPageableResponse is a generic Data Transfer Object that provides detailed pagination information for list endpoints. It wraps the response data with comprehensive metadata about the current page and the entire dataset.Type Parameter
The type of items contained in the page. Can be any response type (e.g.,
BookResponse, UserResponse).Response Fields
The list of items on the current page. Each item is of type
T.The number of items on the current page. This may be less than
limit on the last page.The maximum number of items per page (page size). This value is typically set in the request parameters.
The starting position (index) of the first item on the current page. Calculated as
(current_page - 1) * limit.The total number of pages available based on the total count and limit.
The total number of items across all pages in the entire dataset.
The number of the previous page. Will be
null if the current page is the first page.The number of the current page (1-indexed).
The number of the next page. Will be
null if the current page is the last page.Pagination Metadata
The response includes several fields to help navigate through paginated results:- Navigation: Use
previous_pageandnext_pageto implement previous/next navigation - Progress: Calculate progress as
current_page / total_pages - Range: The current page shows items from index
offsettooffset + count - 1 - Completion: Check if
next_pageisnullto determine if you’ve reached the last page
Example Response (Books)
Example Response (Users)
Usage in API Endpoints
The CustomPageableResponse is typically used in list endpoints that support pagination:GET /api/v1/books- ReturnsCustomPageableResponse<BookResponse>GET /api/v1/users- ReturnsCustomPageableResponse<UserResponse>
page: The page number to retrieve (1-indexed)sizeorlimit: The number of items per pagesort: Optional sorting criteria