mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 19:40:13 +03:00
Add failing test for extra action schemas
This commit is contained in:
parent
d9f541836b
commit
92bb9ec3e9
|
@ -720,6 +720,31 @@ class TestAutoSchema(TestCase):
|
||||||
assert len(fields) == 2
|
assert len(fields) == 2
|
||||||
assert "my_extra_field" in [f.name for f in fields]
|
assert "my_extra_field" in [f.name for f in fields]
|
||||||
|
|
||||||
|
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
||||||
|
def test_viewset_action_with_schema(self):
|
||||||
|
class CustomViewSet(GenericViewSet):
|
||||||
|
@action(detail=True, schema=AutoSchema(manual_fields=[
|
||||||
|
coreapi.Field(
|
||||||
|
"my_extra_field",
|
||||||
|
required=True,
|
||||||
|
location="path",
|
||||||
|
schema=coreschema.String()
|
||||||
|
),
|
||||||
|
]))
|
||||||
|
def extra_action(self, pk, **kwargs):
|
||||||
|
pass
|
||||||
|
|
||||||
|
router = SimpleRouter()
|
||||||
|
router.register(r'detail', CustomViewSet, base_name='detail')
|
||||||
|
|
||||||
|
generator = SchemaGenerator()
|
||||||
|
view = generator.create_view(router.urls[0].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]
|
||||||
|
|
||||||
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
|
||||||
def test_view_with_manual_schema(self):
|
def test_view_with_manual_schema(self):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user