Add test for #382
parent
1635e5e095
commit
acc204e4ea
|
|
@ -1,13 +1,19 @@
|
|||
from rest_framework import viewsets
|
||||
from rest_framework.pagination import BasePagination
|
||||
|
||||
from .models import Identity, Person
|
||||
from .serializers import IdentitySerializer, PersonSerializer
|
||||
|
||||
|
||||
class UnknownPagination(BasePagination):
|
||||
paginator_query_args = ['unknown_paginator']
|
||||
|
||||
|
||||
class PersonViewSet(viewsets.ModelViewSet):
|
||||
model = Person
|
||||
queryset = Person.objects
|
||||
serializer_class = PersonSerializer
|
||||
pagination_class = UnknownPagination
|
||||
|
||||
|
||||
class IdentityViewSet(viewsets.ModelViewSet):
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
from drf_yasg import openapi
|
||||
from drf_yasg.inspectors import PaginatorInspector, NotHandled
|
||||
|
||||
|
||||
class UnknownPaginatorInspector(PaginatorInspector):
|
||||
def get_paginator_parameters(self, paginator):
|
||||
if hasattr(paginator, 'paginator_query_args'):
|
||||
return [openapi.Parameter(name=arg, in_=openapi.IN_QUERY, type=openapi.TYPE_STRING)
|
||||
for arg in getattr(paginator, 'paginator_query_args')]
|
||||
|
||||
return NotHandled
|
||||
|
|
@ -140,7 +140,12 @@ SWAGGER_SETTINGS = {
|
|||
'clientId': OAUTH2_CLIENT_ID,
|
||||
'clientSecret': OAUTH2_CLIENT_SECRET,
|
||||
'appName': OAUTH2_APP_NAME,
|
||||
}
|
||||
},
|
||||
"DEFAULT_PAGINATOR_INSPECTORS": [
|
||||
'testproj.inspectors.UnknownPaginatorInspector',
|
||||
'drf_yasg.inspectors.DjangoRestResponsePagination',
|
||||
'drf_yasg.inspectors.CoreAPICompatInspector',
|
||||
]
|
||||
}
|
||||
|
||||
REDOC_SETTINGS = {
|
||||
|
|
|
|||
|
|
@ -276,7 +276,10 @@ paths:
|
|||
get:
|
||||
operationId: people_list
|
||||
description: ''
|
||||
parameters: []
|
||||
parameters:
|
||||
- name: unknown_paginator
|
||||
in: query
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: ''
|
||||
|
|
|
|||
Loading…
Reference in New Issue