diff --git a/tests/test_schemas.py b/tests/test_schemas.py index 56692d4f59..2f2b659286 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -7,7 +7,7 @@ from django.test import TestCase, override_settings from rest_framework import ( - filters, generics, pagination, permissions, serializers + filters, generics, pagination, permissions, serializers, routers ) from rest_framework.compat import coreapi, coreschema, get_regex_pattern from rest_framework.decorators import ( @@ -547,6 +547,33 @@ class CustomView(APIView): assert len(fields) == 2 assert "my_extra_field" in [f.name for f in fields] + def test_detail_route(self): + + class AViewSet(GenericViewSet): + @detail_route(schema=AutoSchema(manual_fields=[ + coreapi.Field( + "my_extra_field", + required=True, + location="path", + schema=coreschema.String() + ), + ])) + def a_detail_route(self, request, my_normal_field): + pass + + router = routers.SimpleRouter() + router.register(r'detail', AViewSet, base_name='detail') + routes = router.urls + + callback = routes[0].callback + generator = SchemaGenerator() + view = generator.create_view(callback, 'GET') + link = view.schema.get_link('/a/url/{id}/', 'GET', '') + fields = link.fields + + assert len(fields) == 2 + assert "my_extra_field" in [f.name for f in fields] + def test_view_with_manual_schema(self): path = '/example'