Skip to content

Commit

Permalink
Add pagination examples to fix DRF spectacular warnings (#3039)
Browse files Browse the repository at this point in the history
* Fix DRF spectacular warnings

* Update api/api/utils/pagination.py

Co-authored-by: Dhruv Bhanushali <[email protected]>
  • Loading branch information
obulat and dhruvkb authored Sep 20, 2023
1 parent d576df6 commit 2a83bc2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions api/api/utils/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,23 @@ def get_paginated_response_schema(self, schema):
"""

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},
}

0 comments on commit 2a83bc2

Please sign in to comment.