drf-yasg icon indicating copy to clipboard operation
drf-yasg copied to clipboard

customized pagination class is not support?

Open MrBeike opened this issue 4 years ago • 7 comments

I'm using pagination_class = newPagination in the view file. 1.newPagination is a customized class base on rest_framework.pagination.PageNumberPagination.(override func get_paginated_response) 2.I got correct Respons result in web test. 3.drf-yasg shows the Respons result by the original rest_framework.pagination.PageNumberPagination.get_paginated_response().(override func is not work)

1 2

MrBeike avatar Feb 03 '21 16:02 MrBeike

I also encountered the same problem

mocobk avatar Feb 17 '21 16:02 mocobk

Same here, doesn't seem to support it. Probably this here: https://github.com/axnsan12/drf-yasg/blob/b99306f71c6a5779b62189df7d9c1f5ea1c794ef/src/drf_yasg/inspectors/query.py#L60-L79

@axnsan12 Could you please take a look at this?

creyD avatar Apr 12 '21 07:04 creyD

You can write your own PaginationInspector subclass and make DRF use it, either through the DEFAULT_PAGINATION_INSPECTOR setting or as an argument to swagger_auto_schema.

etene avatar Apr 13 '21 09:04 etene

@axnsan12 Could you please confirm this or propose a solution?

creyD avatar May 03 '21 17:05 creyD

@axnsan12 Hi, could you please take a look?

creyD avatar May 20 '21 12:05 creyD

Weird. I would have expected it to generate the schema based on the results of paginator.get_paginated_response_schema(), not hardcoded for the three base types provided by DRF. Spent a day to debug why my custom get_paginated_response_schema() wasn't getting called at all when accessing the docs.

marcosox avatar Mar 03 '23 11:03 marcosox