api: fix items of list fields having nullable set

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-09-10 18:15:51 +02:00
parent 169e748a78
commit df4c8003b8
4 changed files with 13 additions and 23 deletions

View File

@ -1,6 +1,8 @@
"""OAuth2Provider API Views"""
from django_filters.filters import AllValuesMultipleFilter
from django_filters.filterset import FilterSet
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import extend_schema_field
from rest_framework.viewsets import ModelViewSet
from authentik.core.api.propertymappings import PropertyMappingSerializer
@ -23,7 +25,7 @@ class ScopeMappingSerializer(PropertyMappingSerializer):
class ScopeMappingFilter(FilterSet):
"""Filter for ScopeMapping"""
managed = AllValuesMultipleFilter(field_name="managed")
managed = extend_schema_field(OpenApiTypes.STR)(AllValuesMultipleFilter(field_name="managed"))
class Meta:
model = ScopeMapping

View File

@ -9,7 +9,12 @@ from django.utils.translation import gettext_lazy as _
from django_filters.filters import AllValuesMultipleFilter
from django_filters.filterset import FilterSet
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiParameter, OpenApiResponse, extend_schema
from drf_spectacular.utils import (
OpenApiParameter,
OpenApiResponse,
extend_schema,
extend_schema_field,
)
from rest_framework.decorators import action
from rest_framework.fields import CharField, FileField, SerializerMethodField
from rest_framework.parsers import MultiPartParser
@ -185,7 +190,7 @@ class SAMLPropertyMappingSerializer(PropertyMappingSerializer):
class SAMLPropertyMappingFilter(FilterSet):
"""Filter for SAMLPropertyMapping"""
managed = AllValuesMultipleFilter(field_name="managed")
managed = extend_schema_field(OpenApiTypes.STR)(AllValuesMultipleFilter(field_name="managed"))
class Meta:
model = SAMLPropertyMapping

View File

@ -5,7 +5,8 @@ from django.http.response import Http404
from django.utils.text import slugify
from django_filters.filters import AllValuesMultipleFilter
from django_filters.filterset import FilterSet
from drf_spectacular.utils import OpenApiResponse, extend_schema
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import OpenApiResponse, extend_schema, extend_schema_field
from rest_framework.decorators import action
from rest_framework.exceptions import ValidationError
from rest_framework.request import Request
@ -122,7 +123,7 @@ class LDAPPropertyMappingSerializer(PropertyMappingSerializer):
class LDAPPropertyMappingFilter(FilterSet):
"""Filter for LDAPPropertyMapping"""
managed = AllValuesMultipleFilter(field_name="managed")
managed = extend_schema_field(OpenApiTypes.STR)(AllValuesMultipleFilter(field_name="managed"))
class Meta:
model = LDAPPropertyMapping

View File

@ -9169,12 +9169,6 @@ paths:
type: array
items:
type: string
nullable: true
title: Managed by authentik
description: Objects which are managed by authentik. These objects are created
and updated automatically. This is flag only indicates that an object can
be overwritten by migrations. You can still modify the objects via the API,
but expect changes to be overwritten in a later update.
explode: true
style: form
- in: query
@ -9413,12 +9407,6 @@ paths:
type: array
items:
type: string
nullable: true
title: Managed by authentik
description: Objects which are managed by authentik. These objects are created
and updated automatically. This is flag only indicates that an object can
be overwritten by migrations. You can still modify the objects via the API,
but expect changes to be overwritten in a later update.
explode: true
style: form
- in: query
@ -9649,12 +9637,6 @@ paths:
type: array
items:
type: string
nullable: true
title: Managed by authentik
description: Objects which are managed by authentik. These objects are created
and updated automatically. This is flag only indicates that an object can
be overwritten by migrations. You can still modify the objects via the API,
but expect changes to be overwritten in a later update.
explode: true
style: form
- in: query