diff --git a/docs/source/specs/openapi.json b/docs/source/specs/openapi.json index 4524e0364..dbd656b2b 100644 --- a/docs/source/specs/openapi.json +++ b/docs/source/specs/openapi.json @@ -1521,7 +1521,7 @@ } }, { - "$ref": "#/components/parameters/QueryLimitNoDefault" + "$ref": "#/components/parameters/QueryLimit" }, { "$ref": "#/components/parameters/QueryOffset" @@ -1529,26 +1529,11 @@ ], "responses": { "200": { - "description": "A list of access objects. By default, this request will not be paginated. To received a paginated response, include the `/?limit=` query parameter.", + "description": "A paginated list of access objects", "content": { "application/json": { "schema": { - "oneOf": [ - { - "$ref": "#/components/schemas/AccessNoPagination" - }, - { - "$ref": "#/components/schemas/AccessPagination" - } - ] - }, - "examples": { - "AccessNoPagination": { - "$ref": "#/components/examples/AccessNoPagination" - }, - "AccessPagination": { - "$ref": "#/components/examples/AccessPagination" - } + "$ref": "#/components/schemas/AccessPagination" } } } @@ -1610,17 +1595,6 @@ "maximum": 1000 } }, - "QueryLimitNoDefault": { - "in": "query", - "name": "limit", - "required": false, - "description": "Parameter for selecting the amount of data returned.", - "schema": { - "type": "integer", - "minimum": 1, - "maximum": 1000 - } - }, "NameFilter": { "in": "query", "name": "name", @@ -2354,24 +2328,6 @@ } ] }, - "AccessNoPagination": { - "allOf": [ - { - "type": "object", - "required": [ - "data" - ], - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/Access" - } - } - } - } - ] - }, "Status": { "required": [ "api_version" @@ -2423,39 +2379,6 @@ } } } - }, - "examples": { - "AccessNoPagination": { - "value": { - "data": [ - { - "permission": "app-name:*:*", - "resourceDefinitions": [] - } - ] - } - }, - "AccessPagination": { - "value": { - "meta": { - "count": 1, - "limit": 10, - "offset": 0 - }, - "links": { - "first": "/access/?application=app-name&limit=10", - "next": null, - "previous": null, - "last": "/access/?application=app-name&limit=10" - }, - "data": [ - { - "permission": "app-name:*:*", - "resourceDefinitions": [] - } - ] - } - } } } } \ No newline at end of file diff --git a/rbac/management/access/view.py b/rbac/management/access/view.py index 7f2da69c8..40446b6a0 100644 --- a/rbac/management/access/view.py +++ b/rbac/management/access/view.py @@ -94,10 +94,9 @@ def get(self, request): def paginator(self): """Return the paginator instance associated with the view, or `None`.""" if not hasattr(self, '_paginator'): + self._paginator = self.pagination_class() if self.pagination_class is None or 'limit' not in self.request.query_params: - self._paginator = None - else: - self._paginator = self.pagination_class() + self._paginator.default_limit = self._paginator.max_limit return self._paginator def paginate_queryset(self, queryset): diff --git a/tests/management/access/test_view.py b/tests/management/access/test_view.py index 1a474780e..4d6dfe40a 100644 --- a/tests/management/access/test_view.py +++ b/tests/management/access/test_view.py @@ -123,7 +123,7 @@ def test_get_access_success(self): self.assertIsNotNone(response.data.get('data')) self.assertIsInstance(response.data.get('data'), list) self.assertEqual(len(response.data.get('data')), 1) - self.assertIsNone(response.data.get('meta')) + self.assertEqual(response.data.get('meta').get('limit'), 1000) self.assertEqual(self.access_data, response.data.get('data')[0]) def test_get_access_with_limit(self):