mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
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:
@@ -2,6 +2,7 @@ from django.shortcuts import get_object_or_404
|
||||
from rest_framework import viewsets
|
||||
from rest_framework.pagination import CursorPagination
|
||||
from rest_framework.exceptions import ValidationError
|
||||
from drf_spectacular.utils import extend_schema, OpenApiParameter, OpenApiTypes
|
||||
|
||||
from bugsink.api_mixins import AtomicRequestMixin
|
||||
|
||||
@@ -69,6 +70,36 @@ class IssueViewSet(AtomicRequestMixin, viewsets.ReadOnlyModelViewSet):
|
||||
def get_queryset(self):
|
||||
return self.queryset
|
||||
|
||||
@extend_schema(
|
||||
parameters=[
|
||||
OpenApiParameter(
|
||||
name="project",
|
||||
type=OpenApiTypes.INT,
|
||||
location=OpenApiParameter.QUERY,
|
||||
required=True,
|
||||
description="Filter issues by project id (required).",
|
||||
),
|
||||
OpenApiParameter(
|
||||
name="sort",
|
||||
type=OpenApiTypes.STR,
|
||||
location=OpenApiParameter.QUERY,
|
||||
required=False,
|
||||
enum=["digest_order", "last_seen"],
|
||||
description="Sort mode (default: digest_order).",
|
||||
),
|
||||
OpenApiParameter(
|
||||
name="order",
|
||||
type=OpenApiTypes.STR,
|
||||
location=OpenApiParameter.QUERY,
|
||||
required=False,
|
||||
enum=["asc", "desc"],
|
||||
description="Sort order (default: asc).",
|
||||
),
|
||||
]
|
||||
)
|
||||
def list(self, request, *args, **kwargs):
|
||||
return super().list(request, *args, **kwargs)
|
||||
|
||||
def filter_queryset(self, queryset):
|
||||
queryset = super().filter_queryset(queryset)
|
||||
if self.action != "list":
|
||||
|
||||
Reference in New Issue
Block a user