diff --git a/tests/test_schemas.py b/tests/test_schemas.py index f929fece5..c898bdee4 100644 --- a/tests/test_schemas.py +++ b/tests/test_schemas.py @@ -104,6 +104,17 @@ class ExampleViewSet(ModelViewSet): assert self.action return super(ExampleViewSet, self).get_serializer(*args, **kwargs) + @action(methods=['get', 'post'], detail=False) + def documented_custom_action(self, request): + """ + get: + A description of the get method on the custom action. + + post: + A description of the post method on the custom action. + """ + pass + if coreapi: schema_view = get_schema_view(title='Example API') @@ -150,6 +161,13 @@ class TestRouterGeneratedSchema(TestCase): action='get' ) }, + 'documented_custom_action': { + 'read': coreapi.Link( + url='/example/documented_custom_action/', + action='get', + description='A description of the get method on the custom action.', + ) + }, 'read': coreapi.Link( url='/example/{id}/', action='get', @@ -245,6 +263,23 @@ class TestRouterGeneratedSchema(TestCase): action='post' ) }, + 'documented_custom_action': { + 'read': coreapi.Link( + url='/example/documented_custom_action/', + action='get', + description='A description of the get method on the custom action.', + ), + 'create': coreapi.Link( + url='/example/documented_custom_action/', + action='post', + description='A description of the post method on the custom action.', + encoding='application/json', + fields=[ + coreapi.Field('a', required=True, location='form', schema=coreschema.String(title='A', description='A field description')), + coreapi.Field('b', required=False, location='form', schema=coreschema.String(title='B')) + ] + ) + }, 'update': coreapi.Link( url='/example/{id}/', action='put', @@ -529,6 +564,13 @@ class TestSchemaGeneratorWithMethodLimitedViewSets(TestCase): action='get' ) }, + 'documented_custom_action': { + 'read': coreapi.Link( + url='/example1/documented_custom_action/', + action='get', + description='A description of the get method on the custom action.', + ), + }, 'read': coreapi.Link( url='/example1/{id}/', action='get',