From df4c8003b88f0c31ea9bfc2939f36adcc272a0f3 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Fri, 10 Sep 2021 18:15:51 +0200 Subject: [PATCH] api: fix items of list fields having nullable set Signed-off-by: Jens Langhammer --- authentik/providers/oauth2/api/scope.py | 4 +++- authentik/providers/saml/api.py | 9 +++++++-- authentik/sources/ldap/api.py | 5 +++-- schema.yml | 18 ------------------ 4 files changed, 13 insertions(+), 23 deletions(-) diff --git a/authentik/providers/oauth2/api/scope.py b/authentik/providers/oauth2/api/scope.py index 645427d50..3ef0814f1 100644 --- a/authentik/providers/oauth2/api/scope.py +++ b/authentik/providers/oauth2/api/scope.py @@ -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 diff --git a/authentik/providers/saml/api.py b/authentik/providers/saml/api.py index e89fd7077..8c3bc7257 100644 --- a/authentik/providers/saml/api.py +++ b/authentik/providers/saml/api.py @@ -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 diff --git a/authentik/sources/ldap/api.py b/authentik/sources/ldap/api.py index a0c280727..918940c30 100644 --- a/authentik/sources/ldap/api.py +++ b/authentik/sources/ldap/api.py @@ -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 diff --git a/schema.yml b/schema.yml index 7c399edd1..c3aba54d4 100644 --- a/schema.yml +++ b/schema.yml @@ -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