Skip to content

Commit 92bb9ec

Browse files
author
Ryan P Kilby
committed
Add failing test for extra action schemas
1 parent d9f5418 commit 92bb9ec

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_schemas.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,31 @@ class CustomView(APIView):
720720
assert len(fields) == 2
721721
assert "my_extra_field" in [f.name for f in fields]
722722

723+
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
724+
def test_viewset_action_with_schema(self):
725+
class CustomViewSet(GenericViewSet):
726+
@action(detail=True, schema=AutoSchema(manual_fields=[
727+
coreapi.Field(
728+
"my_extra_field",
729+
required=True,
730+
location="path",
731+
schema=coreschema.String()
732+
),
733+
]))
734+
def extra_action(self, pk, **kwargs):
735+
pass
736+
737+
router = SimpleRouter()
738+
router.register(r'detail', CustomViewSet, base_name='detail')
739+
740+
generator = SchemaGenerator()
741+
view = generator.create_view(router.urls[0].callback, 'GET')
742+
link = view.schema.get_link('/a/url/{id}/', 'GET', '')
743+
fields = link.fields
744+
745+
assert len(fields) == 2
746+
assert "my_extra_field" in [f.name for f in fields]
747+
723748
@pytest.mark.skipif(not coreapi, reason='coreapi is not installed')
724749
def test_view_with_manual_schema(self):
725750

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy