Skip to content
Snippets Groups Projects
Commit 4cb57363 authored by Erwan Rouchet's avatar Erwan Rouchet Committed by Bastien Abadie
Browse files

Add x-paginated in OpenAPI schema

parent f4cb4f7a
No related branches found
No related tags found
1 merge request!1453Add x-paginated in OpenAPI schema
......@@ -23,3 +23,14 @@ class AutoSchema(BaseAutoSchema):
We want to specify tags manually, so we return nothing instead.
"""
return []
def get_operation(self, *args, **kwargs):
"""
Add an `x-paginated` property to each operation to allow the API client to tell whether
or not to paginate when someone uses the pagination helper.
When either _is_list_view() or _get_paginator() return False or None respectively,
Spectacular does not include any pagination parameters.
"""
operation = super().get_operation(*args, **kwargs)
operation['x-paginated'] = self._is_list_view() and self._get_paginator() is not None
return operation
......@@ -57,6 +57,7 @@ class TestAutoSchema(TestCase):
{'tokenAuth': []},
{'agentAuth': []}
],
'x-paginated': False,
}
)
self.assertDictEqual(registry[('DeprecatedException', ResolvedComponent.SCHEMA)].schema, {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment