Skip to content

Commit 7e18120

Browse files
committed
add feature to disallow to disable pagination
1 parent da67723 commit 7e18120

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

docs/configuration.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ You have access to 3 configration keys:
88
* PAGE_SIZE: the default page size (default is 30)
99
* MAX_PAGE_SIZE: the maximum page size. If you speficy a page size greater than this value you will receive 400 Bad Request response.
1010
* MAX_INCLUDE_DEPTH: the maximum length of an include through schema relationships
11+
* ALLOW_DISABLE_PAGINATION: if you want to disallow to disable pagination you can set this configuration key to False

flask_rest_jsonapi/querystring.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ def pagination(self):
111111
except ValueError:
112112
raise BadRequest("Parse error", source={'parameter': 'page[{}]'.format(key)})
113113

114+
if current_app.config.get('ALLOW_DISABLE_PAGINATION', True) is False and int(result.get('size', 1)) == 0:
115+
raise BadRequest("You are not allowed to disable pagination", source={'parameter': 'page[size]'})
116+
114117
if current_app.config.get('MAX_PAGE_SIZE') is not None and 'size' in result:
115118
if int(result['size']) > current_app.config['MAX_PAGE_SIZE']:
116119
raise BadRequest("Maximum page size is {}".format(current_app.config['MAX_PAGE_SIZE']),

0 commit comments

Comments
 (0)