Repository: svthalia/concrexit

Issue:
Swagger is broken
### Describe the bug
Swagger does not load

### How to reproduce
Steps to reproduce the behaviour:
1. Go to `/api/docs`

### Expected behaviour
See a list of API endpoints

### Screenshots
![image](https://github.com/svthalia/concrexit/assets/7569492/2c4a0c4d-c118-4024-aae1-d616be8d5995)

### Additional context
```
Internal Server Error: /api/v2/schema
Traceback (most recent call last):
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/django/core/handlers/exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/django/core/handlers/base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/django/views/decorators/csrf.py", line 56, in wrapper_view
    return view_func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/django/views/generic/base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/rest_framework/schemas/views.py", line 48, in handle_exception
    return super().handle_exception(exc)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/rest_framework/schemas/views.py", line 37, in get
    schema = self.schema_generator.get_schema(request, self.public)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/code/thalia/concrexit/website/thaliawebsite/api/openapi.py", line 15, in get_schema
    schema = super().get_schema(request, public)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/rest_framework/schemas/openapi.py", line 81, in get_schema
    operation = view.schema.get_operation(path, method)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/code/thalia/concrexit/website/thaliawebsite/api/openapi.py", line 34, in get_operation
    operation = super().get_operation(path, method)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/rest_framework/schemas/openapi.py", line 159, in get_operation
    operation['responses'] = self.get_responses(path, method)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/rest_framework/schemas/openapi.py", line 672, in get_responses
    serializer = self.get_response_serializer(path, method)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/.cache/pypoetry/virtualenvs/concrexit--pvm0Zyy-py3.11/lib/python3.11/site-packages/rest_framework/schemas/openapi.py", line 637, in get_response_serializer
    return self.get_serializer(path, method)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/quinten/code/thalia/concrexit/website/thaliawebsite/api/openapi.py", line 74, in get_serializer
    return view.get_serializer()
           ^^^^^^^^^^^^^^^^^^^^^
TypeError: MemberListView.get_serializer() missing 1 required positional argument: 'members'
```



Discussion:

Resolving patch:
diff --git a/website/members/api/v2/views.py b/website/members/api/v2/views.py
--- a/website/members/api/v2/views.py
+++ b/website/members/api/v2/views.py
@@ -28,9 +28,11 @@ class MemberListView(ListAPIView):
         .prefetch_related("membership_set")
     )
 
-    def get_serializer(self, members, *args, **kwargs):
-        fetch_thumbnails_db([member.profile.photo for member in members])
-        return super().get_serializer(members, *args, **kwargs)
+    def get_serializer(self, *args, **kwargs):
+        if len(args) > 0:
+            members = args[0]
+            fetch_thumbnails_db([member.profile.photo for member in members])
+        return super().get_serializer(*args, **kwargs)
 
     permission_classes = [
         IsAuthenticatedOrTokenHasScope,
diff --git a/website/partners/api/v2/views.py b/website/partners/api/v2/views.py
--- a/website/partners/api/v2/views.py
+++ b/website/partners/api/v2/views.py
@@ -20,9 +20,11 @@ class PartnerListView(ListAPIView):
         framework_filters.SearchFilter,
     )
 
-    def get_serializer(self, partners, *args, **kwargs):
-        fetch_thumbnails_db([partner.logo for partner in partners])
-        return super().get_serializer(partners, *args, **kwargs)
+    def get_serializer(self, *args, **kwargs):
+        if len(args) > 0:
+            partners = args[0]
+            fetch_thumbnails_db([partner.logo for partner in partners])
+        return super().get_serializer(*args, **kwargs)
 
     ordering_fields = ("name", "pk")
     search_fields = ("name",)
diff --git a/website/photos/api/v2/views.py b/website/photos/api/v2/views.py
--- a/website/photos/api/v2/views.py
+++ b/website/photos/api/v2/views.py
@@ -22,9 +22,11 @@ class AlbumListView(ListAPIView):
 
     serializer_class = AlbumListSerializer
 
-    def get_serializer(self, albums, *args, **kwargs):
-        fetch_thumbnails_db([album.cover.file for album in albums if album.cover])
-        return super().get_serializer(albums, *args, **kwargs)
+    def get_serializer(self, *args, **kwargs):
+        if len(args) > 0:
+            albums = args[0]
+            fetch_thumbnails_db([album.cover.file for album in albums if album.cover])
+        return super().get_serializer(*args, **kwargs)
 
     queryset = Album.objects.filter(hidden=False).select_related("_cover")
 
@@ -90,9 +92,11 @@ def get(self, request, *args, **kwargs):
             )
         return self.list(request, *args, **kwargs)
 
-    def get_serializer(self, photos, *args, **kwargs):
-        fetch_thumbnails_db([photo.file for photo in photos])
-        return super().get_serializer(photos, *args, **kwargs)
+    def get_serializer(self, *args, **kwargs):
+        if len(args) > 0:
+            photos = args[0]
+            fetch_thumbnails_db([photo.file for photo in photos])
+        return super().get_serializer(*args, **kwargs)
 
     def get_queryset(self):
         return (


Test patch: