Skip to content

Commit 7fb11bf

Browse files
committed
Removed exclude_from_schema per deprecation policy.
1 parent 5627d91 commit 7fb11bf

File tree

3 files changed

+2
-49
lines changed

3 files changed

+2
-49
lines changed

rest_framework/decorators.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
from rest_framework.views import APIView
1818

1919

20-
def api_view(http_method_names=None, exclude_from_schema=False):
20+
def api_view(http_method_names=None):
2121
"""
2222
Decorator that converts a function-based view into an APIView subclass.
2323
Takes a list of allowed methods for the view as an argument.
@@ -77,15 +77,8 @@ def handler(self, *args, **kwargs):
7777
WrappedAPIView.schema = getattr(func, 'schema',
7878
APIView.schema)
7979

80-
if exclude_from_schema:
81-
warnings.warn(
82-
"The `exclude_from_schema` argument to `api_view` is deprecated. "
83-
"Use the `schema` decorator instead, passing `None`.",
84-
DeprecationWarning
85-
)
86-
WrappedAPIView.exclude_from_schema = exclude_from_schema
87-
8880
return WrappedAPIView.as_view()
81+
8982
return decorator
9083

9184

rest_framework/schemas/generators.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,14 +207,6 @@ def should_include_endpoint(self, path, callback):
207207
if not is_api_view(callback):
208208
return False # Ignore anything except REST framework views.
209209

210-
if hasattr(callback.cls, 'exclude_from_schema'):
211-
fmt = ("The `{}.exclude_from_schema` attribute is deprecated. "
212-
"Set `schema = None` instead.")
213-
msg = fmt.format(callback.cls.__name__)
214-
warnings.warn(msg, DeprecationWarning)
215-
if getattr(callback.cls, 'exclude_from_schema', False):
216-
return False
217-
218210
if callback.cls.schema is None:
219211
return False
220212

tests/test_schemas.py

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,38 +1032,6 @@ def test_should_include_endpoint_excludes_correctly(self):
10321032

10331033
assert should_include == expected
10341034

1035-
def test_deprecations(self):
1036-
with pytest.warns(DeprecationWarning) as record:
1037-
@api_view(["GET"], exclude_from_schema=True)
1038-
def view(request):
1039-
pass
1040-
1041-
assert len(record) == 1
1042-
assert str(record[0].message) == (
1043-
"The `exclude_from_schema` argument to `api_view` is deprecated. "
1044-
"Use the `schema` decorator instead, passing `None`."
1045-
)
1046-
1047-
class OldFashionedExcludedView(APIView):
1048-
exclude_from_schema = True
1049-
1050-
def get(self, request, *args, **kwargs):
1051-
pass
1052-
1053-
patterns = [
1054-
url('^excluded-old-fashioned/$', OldFashionedExcludedView.as_view()),
1055-
]
1056-
1057-
inspector = EndpointEnumerator(patterns)
1058-
with pytest.warns(DeprecationWarning) as record:
1059-
inspector.get_api_endpoints()
1060-
1061-
assert len(record) == 1
1062-
assert str(record[0].message) == (
1063-
"The `OldFashionedExcludedView.exclude_from_schema` attribute is "
1064-
"deprecated. Set `schema = None` instead."
1065-
)
1066-
10671035

10681036
@api_view(["GET"])
10691037
def simple_fbv(request):

0 commit comments

Comments
 (0)