mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 12:00:12 +03:00
Merge e2793aced1
into 97f7a82b37
This commit is contained in:
commit
85615af988
|
@ -7,7 +7,7 @@ from django.http import Http404
|
|||
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 TestDescriptor(TestCase):
|
|||
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'
|
||||
|
|
Loading…
Reference in New Issue
Block a user