Add test for #382
parent
1635e5e095
commit
acc204e4ea
|
|
@ -1,13 +1,19 @@
|
||||||
from rest_framework import viewsets
|
from rest_framework import viewsets
|
||||||
|
from rest_framework.pagination import BasePagination
|
||||||
|
|
||||||
from .models import Identity, Person
|
from .models import Identity, Person
|
||||||
from .serializers import IdentitySerializer, PersonSerializer
|
from .serializers import IdentitySerializer, PersonSerializer
|
||||||
|
|
||||||
|
|
||||||
|
class UnknownPagination(BasePagination):
|
||||||
|
paginator_query_args = ['unknown_paginator']
|
||||||
|
|
||||||
|
|
||||||
class PersonViewSet(viewsets.ModelViewSet):
|
class PersonViewSet(viewsets.ModelViewSet):
|
||||||
model = Person
|
model = Person
|
||||||
queryset = Person.objects
|
queryset = Person.objects
|
||||||
serializer_class = PersonSerializer
|
serializer_class = PersonSerializer
|
||||||
|
pagination_class = UnknownPagination
|
||||||
|
|
||||||
|
|
||||||
class IdentityViewSet(viewsets.ModelViewSet):
|
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,
|
'clientId': OAUTH2_CLIENT_ID,
|
||||||
'clientSecret': OAUTH2_CLIENT_SECRET,
|
'clientSecret': OAUTH2_CLIENT_SECRET,
|
||||||
'appName': OAUTH2_APP_NAME,
|
'appName': OAUTH2_APP_NAME,
|
||||||
}
|
},
|
||||||
|
"DEFAULT_PAGINATOR_INSPECTORS": [
|
||||||
|
'testproj.inspectors.UnknownPaginatorInspector',
|
||||||
|
'drf_yasg.inspectors.DjangoRestResponsePagination',
|
||||||
|
'drf_yasg.inspectors.CoreAPICompatInspector',
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
REDOC_SETTINGS = {
|
REDOC_SETTINGS = {
|
||||||
|
|
|
||||||
|
|
@ -276,7 +276,10 @@ paths:
|
||||||
get:
|
get:
|
||||||
operationId: people_list
|
operationId: people_list
|
||||||
description: ''
|
description: ''
|
||||||
parameters: []
|
parameters:
|
||||||
|
- name: unknown_paginator
|
||||||
|
in: query
|
||||||
|
type: string
|
||||||
responses:
|
responses:
|
||||||
'200':
|
'200':
|
||||||
description: ''
|
description: ''
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue