admin: fix mismatched Swagger schema
This commit is contained in:
parent
77d5ba2862
commit
ea784d47f4
|
@ -7,14 +7,14 @@ from django.http.response import Http404
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from drf_yasg2.utils import swagger_auto_schema
|
from drf_yasg2.utils import swagger_auto_schema
|
||||||
from rest_framework.decorators import action
|
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.permissions import IsAdminUser
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
from rest_framework.response import Response
|
from rest_framework.response import Response
|
||||||
from rest_framework.serializers import Serializer
|
from rest_framework.serializers import Serializer
|
||||||
from rest_framework.viewsets import ViewSet
|
from rest_framework.viewsets import ViewSet
|
||||||
|
|
||||||
from authentik.events.monitored_tasks import TaskInfo
|
from authentik.events.monitored_tasks import TaskInfo, TaskResultStatus
|
||||||
|
|
||||||
|
|
||||||
class TaskSerializer(Serializer):
|
class TaskSerializer(Serializer):
|
||||||
|
@ -24,7 +24,9 @@ class TaskSerializer(Serializer):
|
||||||
task_description = CharField()
|
task_description = CharField()
|
||||||
task_finish_timestamp = DateTimeField(source="finish_timestamp")
|
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")
|
messages = ListField(source="result.messages")
|
||||||
|
|
||||||
def create(self, validated_data: dict) -> Model:
|
def create(self, validated_data: dict) -> Model:
|
||||||
|
|
|
@ -55,7 +55,7 @@ class VersionViewSet(ListModelMixin, GenericViewSet):
|
||||||
def get_queryset(self): # pragma: no cover
|
def get_queryset(self): # pragma: no cover
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@swagger_auto_schema(responses={200: VersionSerializer(many=True)})
|
@swagger_auto_schema(responses={200: VersionSerializer(many=False)})
|
||||||
def list(self, request: Request) -> Response:
|
def list(self, request: Request) -> Response:
|
||||||
"""Get running and latest version."""
|
"""Get running and latest version."""
|
||||||
return Response(VersionSerializer(True).data)
|
return Response(VersionSerializer(True).data)
|
||||||
|
|
|
@ -150,7 +150,6 @@ SWAGGER_SETTINGS = {
|
||||||
REST_FRAMEWORK = {
|
REST_FRAMEWORK = {
|
||||||
"DEFAULT_PAGINATION_CLASS": "authentik.api.pagination.Pagination",
|
"DEFAULT_PAGINATION_CLASS": "authentik.api.pagination.Pagination",
|
||||||
"PAGE_SIZE": 100,
|
"PAGE_SIZE": 100,
|
||||||
"DATETIME_FORMAT": "%s",
|
|
||||||
"DEFAULT_FILTER_BACKENDS": [
|
"DEFAULT_FILTER_BACKENDS": [
|
||||||
"rest_framework_guardian.filters.ObjectPermissionsFilter",
|
"rest_framework_guardian.filters.ObjectPermissionsFilter",
|
||||||
"django_filters.rest_framework.DjangoFilterBackend",
|
"django_filters.rest_framework.DjangoFilterBackend",
|
||||||
|
|
|
@ -96,9 +96,6 @@ paths:
|
||||||
'200':
|
'200':
|
||||||
description: Get running and latest version.
|
description: Get running and latest version.
|
||||||
schema:
|
schema:
|
||||||
description: ''
|
|
||||||
type: array
|
|
||||||
items:
|
|
||||||
$ref: '#/definitions/Version'
|
$ref: '#/definitions/Version'
|
||||||
tags:
|
tags:
|
||||||
- admin
|
- admin
|
||||||
|
@ -9338,7 +9335,11 @@ definitions:
|
||||||
format: date-time
|
format: date-time
|
||||||
status:
|
status:
|
||||||
title: Status
|
title: Status
|
||||||
type: integer
|
type: string
|
||||||
|
enum:
|
||||||
|
- SUCCESSFUL
|
||||||
|
- WARNING
|
||||||
|
- ERROR
|
||||||
messages:
|
messages:
|
||||||
description: ''
|
description: ''
|
||||||
type: array
|
type: array
|
||||||
|
|
Reference in New Issue