Add Swagger using drf-spectacular

See #146

DRF 3.16 and Django 5.2 are not in drf-spectacular's published
list of supported but here's some sources that give reason to believe
they are supported _in practice_:

* https://github.com/tfranzel/drf-spectacular/issues/1417
* https://github.com/tfranzel/drf-spectacular/issues/1414
This commit is contained in:
Klaas van Schelven
2025-09-12 11:32:16 +02:00
parent 9ad66d7b50
commit a4e84fa0a3
8 changed files with 120 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
from django.shortcuts import get_object_or_404
from rest_framework import viewsets
from drf_spectacular.utils import extend_schema, OpenApiParameter, OpenApiTypes
from bugsink.api_pagination import AscDescCursorPagination
from bugsink.api_mixins import ExpandViewSetMixin, AtomicRequestMixin
@@ -33,6 +34,20 @@ class ProjectViewSet(AtomicRequestMixin, ExpandViewSetMixin, viewsets.ModelViewS
http_method_names = ["get", "post", "patch", "head", "options"]
pagination_class = ProjectPagination
@extend_schema(
parameters=[
OpenApiParameter(
name="team",
type=OpenApiTypes.UUID,
location=OpenApiParameter.QUERY,
required=False,
description="Optional filter by team UUID.",
),
]
)
def list(self, request, *args, **kwargs):
return super().list(request, *args, **kwargs)
def filter_queryset(self, queryset):
if self.action != "list":
return queryset