From 7f8afad5285a8d17102d4ed35ff43d17b2298720 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Sun, 11 Sep 2022 23:08:31 +0200 Subject: [PATCH] *: fix API Schema generation warnings Signed-off-by: Jens Langhammer --- authentik/admin/api/tasks.py | 20 ++++++++++++++++++-- authentik/tenants/api.py | 4 ++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/authentik/admin/api/tasks.py b/authentik/admin/api/tasks.py index dc2d73a66..c9ae28951 100644 --- a/authentik/admin/api/tasks.py +++ b/authentik/admin/api/tasks.py @@ -5,7 +5,7 @@ from django.contrib import messages from django.http.response import Http404 from django.utils.translation import gettext_lazy as _ from drf_spectacular.types import OpenApiTypes -from drf_spectacular.utils import OpenApiResponse, extend_schema +from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema from rest_framework.decorators import action from rest_framework.fields import CharField, ChoiceField, DateTimeField, ListField from rest_framework.permissions import IsAdminUser @@ -58,7 +58,15 @@ class TaskViewSet(ViewSet): responses={ 200: TaskSerializer(many=False), 404: OpenApiResponse(description="Task not found"), - } + }, + parameters=[ + OpenApiParameter( + "id", + type=OpenApiTypes.STR, + location=OpenApiParameter.PATH, + required=True, + ), + ], ) # pylint: disable=invalid-name def retrieve(self, request: Request, pk=None) -> Response: @@ -81,6 +89,14 @@ class TaskViewSet(ViewSet): 404: OpenApiResponse(description="Task not found"), 500: OpenApiResponse(description="Failed to retry task"), }, + parameters=[ + OpenApiParameter( + "id", + type=OpenApiTypes.STR, + location=OpenApiParameter.PATH, + required=True, + ), + ], ) @action(detail=True, methods=["post"]) # pylint: disable=invalid-name diff --git a/authentik/tenants/api.py b/authentik/tenants/api.py index 758743d55..770a74607 100644 --- a/authentik/tenants/api.py +++ b/authentik/tenants/api.py @@ -4,7 +4,7 @@ from typing import Any from drf_spectacular.utils import extend_schema from rest_framework.decorators import action from rest_framework.exceptions import ValidationError -from rest_framework.fields import CharField, ListField, ReadOnlyField +from rest_framework.fields import CharField, ListField from rest_framework.permissions import AllowAny from rest_framework.request import Request from rest_framework.response import Response @@ -76,7 +76,7 @@ class CurrentTenantSerializer(PassiveSerializer): flow_unenrollment = CharField(source="flow_unenrollment.slug", required=False) flow_user_settings = CharField(source="flow_user_settings.slug", required=False) - default_locale = ReadOnlyField() + default_locale = CharField(read_only=True) class TenantViewSet(UsedByMixin, ModelViewSet):