Skip to content

Commit

Permalink
enable clearing auth methods with empty list #99
Browse files Browse the repository at this point in the history
  • Loading branch information
tfranzel committed Dec 8, 2021
1 parent fb4c841 commit 57c1a30
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drf_spectacular/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def get_override_parameters(self):
return super().get_override_parameters()

def get_auth(self):
if auth and is_in_scope(self):
if auth is not None and is_in_scope(self):
return auth
return super().get_auth()

Expand Down
10 changes: 10 additions & 0 deletions tests/test_regressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2832,3 +2832,13 @@ class XViewset(viewsets.ModelViewSet):
response_types = list(schema['paths']['/x/']['post']['responses']['201']['content'].keys())

assert response_types == request_types == ['multipart/form-data']


def test_empty_auth_override(no_warnings):
@extend_schema(responses=SimpleSerializer, auth=[])
@api_view(['GET'])
def view_func(request, format=None):
pass # pragma: no cover

schema = generate_schema('/x/', view_function=view_func)
assert 'security' not in schema['paths']['/x/']['get']

0 comments on commit 57c1a30

Please # to comment.