Coverage for app/venv/lib/python3.14/site-packages/weblate/api/pagination.py: 100%
15 statements
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
« prev ^ index » next coverage.py v7.15.2, created at 2026-10-07 07:15 +0000
1# Copyright © Michal Čihař <michal@weblate.org>
2#
3# SPDX-License-Identifier: GPL-3.0-or-later
5from typing import cast
7from rest_framework.pagination import PageNumberPagination
8from rest_framework.settings import api_settings
11class StandardPagination(PageNumberPagination):
12 page_size = cast("int", api_settings.PAGE_SIZE)
13 page_size_query_param = "page_size"
14 max_page_size = 1000
16 def get_paginated_response_schema(self, data):
17 """
18 Make the response schema compatible with OpenAPI 3.1 specification.
20 As of drf-spectacular[sidecar]>=0.28.0,<0.29, pagination schemas are not
21 compatible by default with OpenAPI 3.1. This method overrides the default.
22 Later updates might fix this issue.
24 https://github.com/tfranzel/drf-spectacular/issues/1360
25 """
26 schema = super().get_paginated_response_schema(data)
27 schema["properties"]["next"].pop("nullable")
28 schema["properties"]["previous"].pop("nullable")
29 return schema
32class LargePagination(StandardPagination):
33 page_size = StandardPagination.page_size * 4
34 max_page_size = 10000