Skip to content

Commit

Permalink
Use a list, not a tuple, for permission_classes (#666)
Browse files Browse the repository at this point in the history
DRF expects permission classes to be in a list:
https://www.django-rest-framework.org/api-guide/permissions

Semantically, this should be a list, as the number of elements is arbitrary.
  • Loading branch information
brianhelba authored Oct 31, 2020
1 parent e3fc299 commit c14a4d4
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ In ``urls.py``:
license=openapi.License(name="BSD License"),
),
public=True,
permission_classes=(permissions.AllowAny,),
permission_classes=[permissions.AllowAny],
)
urlpatterns = [
Expand Down
2 changes: 1 addition & 1 deletion src/drf_yasg/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_schema_view(info=None, url=None, patterns=None, urlconf=None, public=Fal
:param list validators: a list of validator names to apply; the only allowed value is ``ssv``, for now
:param type generator_class: schema generator class to use; should be a subclass of :class:`.OpenAPISchemaGenerator`
:param tuple authentication_classes: authentication classes for the schema view itself
:param tuple permission_classes: permission classes for the schema view itself
:param list permission_classes: permission classes for the schema view itself
:return: SchemaView class
:rtype: type[drf_yasg.views.SchemaView]
"""
Expand Down
4 changes: 2 additions & 2 deletions testproj/testproj/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@

# Django Rest Framework
REST_FRAMEWORK = {
'DEFAULT_PERMISSION_CLASSES': (
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated',
)
]
}

OAUTH2_CLIENT_ID = '12ee6bgxtpSEgP8TioWcHSXOiDBOUrVav4mRbVEs'
Expand Down
2 changes: 1 addition & 1 deletion testproj/testproj/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
SchemaView = get_schema_view(
validators=['ssv', 'flex'],
public=True,
permission_classes=(permissions.AllowAny,),
permission_classes=[permissions.AllowAny],
)


Expand Down
2 changes: 1 addition & 1 deletion tests/urlconfs/non_public_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
view = get_schema_view(
openapi.Info('bla', 'ble'),
public=False,
permission_classes=(permissions.AllowAny,)
permission_classes=[permissions.AllowAny]
)
view = view.without_ui(cache_timeout=None)

Expand Down

0 comments on commit c14a4d4

Please sign in to comment.