File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -720,6 +720,31 @@ class CustomView(APIView):
720
720
assert len (fields ) == 2
721
721
assert "my_extra_field" in [f .name for f in fields ]
722
722
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
+
723
748
@pytest .mark .skipif (not coreapi , reason = 'coreapi is not installed' )
724
749
def test_view_with_manual_schema (self ):
725
750
You can’t perform that action at this time.
0 commit comments