flask-smorest icon indicating copy to clipboard operation
flask-smorest copied to clipboard

How to represent infinite item/page count in 'x-pagination' header?

Open der-joel opened this issue 3 years ago • 0 comments

According to the docs:

The view function must also specify the total number of elements by setting it as item_count attribute of the PaginationParameters object.

I was wondering to which value item_count should be set if the paginated collection has infinite length. Python's native infinity representation math.inf/float('inf') does not work since PaginationMetadataSchema only allows integer values (OverflowError). If no value is passed the x-pagination header will not appear in the response headers (no information on current, first and next page).

Also per default JSON has no representation of infinity, so maybe in this case total, total_pages and last_page should be removed from the header? An alternative solution could be "Infinity" which coerces to Infinity in JS, but this might confuse some since it's string-type.

der-joel avatar Jun 20 '22 13:06 der-joel