diff --git a/authentik/admin/api/tasks.py b/authentik/admin/api/tasks.py index ddeed8fb9..63c82394d 100644 --- a/authentik/admin/api/tasks.py +++ b/authentik/admin/api/tasks.py @@ -7,14 +7,14 @@ from django.http.response import Http404 from django.utils.translation import gettext_lazy as _ from drf_yasg2.utils import swagger_auto_schema from rest_framework.decorators import action -from rest_framework.fields import CharField, DateTimeField, IntegerField, ListField +from rest_framework.fields import CharField, ChoiceField, DateTimeField, ListField from rest_framework.permissions import IsAdminUser from rest_framework.request import Request from rest_framework.response import Response from rest_framework.serializers import Serializer from rest_framework.viewsets import ViewSet -from authentik.events.monitored_tasks import TaskInfo +from authentik.events.monitored_tasks import TaskInfo, TaskResultStatus class TaskSerializer(Serializer): @@ -24,7 +24,9 @@ class TaskSerializer(Serializer): task_description = CharField() task_finish_timestamp = DateTimeField(source="finish_timestamp") - status = IntegerField(source="result.status.value") + status = ChoiceField(source="result.status.name", choices=[ + (x.name, x.name) for x in TaskResultStatus + ]) messages = ListField(source="result.messages") def create(self, validated_data: dict) -> Model: diff --git a/authentik/admin/api/version.py b/authentik/admin/api/version.py index 9201b2369..2d7a941d0 100644 --- a/authentik/admin/api/version.py +++ b/authentik/admin/api/version.py @@ -55,7 +55,7 @@ class VersionViewSet(ListModelMixin, GenericViewSet): def get_queryset(self): # pragma: no cover return None - @swagger_auto_schema(responses={200: VersionSerializer(many=True)}) + @swagger_auto_schema(responses={200: VersionSerializer(many=False)}) def list(self, request: Request) -> Response: """Get running and latest version.""" return Response(VersionSerializer(True).data) diff --git a/authentik/root/settings.py b/authentik/root/settings.py index abfe9485a..3e1e534f2 100644 --- a/authentik/root/settings.py +++ b/authentik/root/settings.py @@ -150,7 +150,6 @@ SWAGGER_SETTINGS = { REST_FRAMEWORK = { "DEFAULT_PAGINATION_CLASS": "authentik.api.pagination.Pagination", "PAGE_SIZE": 100, - "DATETIME_FORMAT": "%s", "DEFAULT_FILTER_BACKENDS": [ "rest_framework_guardian.filters.ObjectPermissionsFilter", "django_filters.rest_framework.DjangoFilterBackend", diff --git a/swagger.yaml b/swagger.yaml index 0ccb3774f..90533ee0a 100755 --- a/swagger.yaml +++ b/swagger.yaml @@ -96,10 +96,7 @@ paths: '200': description: Get running and latest version. schema: - description: '' - type: array - items: - $ref: '#/definitions/Version' + $ref: '#/definitions/Version' tags: - admin parameters: [] @@ -9338,7 +9335,11 @@ definitions: format: date-time status: title: Status - type: integer + type: string + enum: + - SUCCESSFUL + - WARNING + - ERROR messages: description: '' type: array