`extend_schema_serializer` examples do not work on custom pagination classes with nested properties
Closed this issue · 1 comments
w00kie commented
Describe the bug
As identified by @AlexChalk in #595 (comment), when using a custom pagination class that has nested properties, the example generation fails to do its magic and falls back to outputting the single example as-is instead of wrapping it with a realistic paginated object.
To Reproduce
Alex gives a good example get_pagination_schema
example for a custom pagination class that would fail:
def get_paginated_response_schema(self, schema):
return {
"type": "object",
"properties": {
"pagination": {
"type": "object",
"properties": {
"count": {"type": "integer", "example": 10},
"next": {
"type": "string",
"nullable": True,
"format": "uri",
"example": None,
},
"previous": {
"type": "string",
"nullable": True,
"format": "uri",
"example": None,
},
"page_size": {"type": "integer", "example": 10},
"num_pages": {"type": "integer", "example": 1},
"current_page": {"type": "integer", "example": 1},
},
},
"data": schema,
},
}
Expected behavior
Ideally the build_listed_example_value
in plumbing.py would recursively look through the paginated schema properties to rebuild a complete example and not fail with a warning when it finds a property without an example.
w00kie commented
Thanks for merging this! 💯