api: fix types for config API

This commit is contained in:
Jens Langhammer 2021-03-03 19:52:56 +01:00
parent ea784d47f4
commit 466723573c
3 changed files with 18 additions and 16 deletions

View File

@ -24,9 +24,10 @@ class TaskSerializer(Serializer):
task_description = CharField()
task_finish_timestamp = DateTimeField(source="finish_timestamp")
status = ChoiceField(source="result.status.name", choices=[
(x.name, x.name) for x in TaskResultStatus
])
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:

View File

@ -1,10 +1,11 @@
"""core Configs API"""
from django.db.models import Model
from drf_yasg2.utils import swagger_auto_schema
from rest_framework.fields import BooleanField, CharField
from rest_framework.permissions import AllowAny
from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.serializers import ReadOnlyField, Serializer
from rest_framework.serializers import Serializer
from rest_framework.viewsets import ViewSet
from authentik.lib.config import CONFIG
@ -13,12 +14,12 @@ from authentik.lib.config import CONFIG
class ConfigSerializer(Serializer):
"""Serialize authentik Config into DRF Object"""
branding_logo = ReadOnlyField()
branding_title = ReadOnlyField()
branding_logo = CharField(read_only=True)
branding_title = CharField(read_only=True)
error_reporting_enabled = ReadOnlyField()
error_reporting_environment = ReadOnlyField()
error_reporting_send_pii = ReadOnlyField()
error_reporting_enabled = BooleanField(read_only=True)
error_reporting_environment = CharField(read_only=True)
error_reporting_send_pii = BooleanField(read_only=True)
def create(self, validated_data: dict) -> Model:
raise NotImplementedError
@ -32,7 +33,7 @@ class ConfigsViewSet(ViewSet):
permission_classes = [AllowAny]
@swagger_auto_schema(responses={200: ConfigSerializer(many=True)})
@swagger_auto_schema(responses={200: ConfigSerializer(many=False)})
def list(self, request: Request) -> Response:
"""Retrive public configuration options"""
config = ConfigSerializer(

View File

@ -5841,10 +5841,7 @@ paths:
'200':
description: Serialize authentik Config into DRF Object
schema:
description: ''
type: array
items:
$ref: '#/definitions/Config'
$ref: '#/definitions/Config'
tags:
- root
parameters: []
@ -11815,21 +11812,24 @@ definitions:
title: Branding logo
type: string
readOnly: true
minLength: 1
branding_title:
title: Branding title
type: string
readOnly: true
minLength: 1
error_reporting_enabled:
title: Error reporting enabled
type: string
type: boolean
readOnly: true
error_reporting_environment:
title: Error reporting environment
type: string
readOnly: true
minLength: 1
error_reporting_send_pii:
title: Error reporting send pii
type: string
type: boolean
readOnly: true
Source:
description: Source Serializer