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""" """OAuth2Provider API Views"""
from django_filters.filters import AllValuesMultipleFilter from django_filters.filters import AllValuesMultipleFilter
from django_filters.filterset import FilterSet 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 rest_framework.viewsets import ModelViewSet
from authentik.core.api.propertymappings import PropertyMappingSerializer from authentik.core.api.propertymappings import PropertyMappingSerializer
@ -23,7 +25,7 @@ class ScopeMappingSerializer(PropertyMappingSerializer):
class ScopeMappingFilter(FilterSet): class ScopeMappingFilter(FilterSet):
"""Filter for ScopeMapping""" """Filter for ScopeMapping"""
managed = AllValuesMultipleFilter(field_name="managed") managed = extend_schema_field(OpenApiTypes.STR)(AllValuesMultipleFilter(field_name="managed"))
class Meta: class Meta:
model = ScopeMapping 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.filters import AllValuesMultipleFilter
from django_filters.filterset import FilterSet from django_filters.filterset import FilterSet
from drf_spectacular.types import OpenApiTypes 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.decorators import action
from rest_framework.fields import CharField, FileField, SerializerMethodField from rest_framework.fields import CharField, FileField, SerializerMethodField
from rest_framework.parsers import MultiPartParser from rest_framework.parsers import MultiPartParser
@ -185,7 +190,7 @@ class SAMLPropertyMappingSerializer(PropertyMappingSerializer):
class SAMLPropertyMappingFilter(FilterSet): class SAMLPropertyMappingFilter(FilterSet):
"""Filter for SAMLPropertyMapping""" """Filter for SAMLPropertyMapping"""
managed = AllValuesMultipleFilter(field_name="managed") managed = extend_schema_field(OpenApiTypes.STR)(AllValuesMultipleFilter(field_name="managed"))
class Meta: class Meta:
model = SAMLPropertyMapping model = SAMLPropertyMapping

View File

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

View File

@ -9169,12 +9169,6 @@ paths:
type: array type: array
items: items:
type: string 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 explode: true
style: form style: form
- in: query - in: query
@ -9413,12 +9407,6 @@ paths:
type: array type: array
items: items:
type: string 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 explode: true
style: form style: form
- in: query - in: query
@ -9649,12 +9637,6 @@ paths:
type: array type: array
items: items:
type: string 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 explode: true
style: form style: form
- in: query - in: query