Skip to content

Openverse is a search engine for openly-licensed media. This monorepo includes all application code.

Add pagination examples to fix DRF spectacular warnings (#3039)

Olga Bulat2a83bc2bfe2d
diff --git a/api/api/utils/pagination.py b/api/api/utils/pagination.py
index 83a0008ea..85e2cf24b 100644
--- a/api/api/utils/pagination.py
+++ b/api/api/utils/pagination.py
@@ -31,16 +31,23 @@ class StandardPagination(PageNumberPagination):
"""
field_descriptions = {
- "result_count": "The total number of items returned by search result.",
- "page_count": "The total number of pages returned by search result.",
- "page_size": "The number of items per page.",
- "page": "The current page number returned in the response.",
+ "result_count": (
+ "The total number of items returned by search result.",
+ 10000,
+ ),
+ "page_count": ("The total number of pages returned by search result.", 20),
+ "page_size": ("The number of items per page.", 20),
+ "page": ("The current page number returned in the response.", 1),
}
return {
"type": "object",
"properties": {
- field: {"type": "integer", "description": description}
- for field, description in field_descriptions.items()
+ field: {
+ "type": "integer",
+ "description": description,
+ "example": example,
+ }
+ for field, (description, example) in field_descriptions.items()
}
| {"results": schema},
}