This repository has been archived by the owner on May 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 45
tags display a string in swagger but in fact a list #47
Comments
same problem |
same problem. Any solutions for this? |
same problem. |
The problem is still there. We reproduced it using drf-spectacular. |
Same here. We should probably write a |
This worked for me: from drf_spectacular.extensions import OpenApiSerializerFieldExtension
from drf_spectacular.openapi import AutoSchema
from drf_spectacular.plumbing import build_array_type, build_basic_type # type: ignore
from drf_spectacular.types import OpenApiTypes
from drf_spectacular.utils import Direction
class TagListSerializerFieldFix(OpenApiSerializerFieldExtension):
target_class = "taggit.serializers.TagListSerializerField"
def map_serializer_field(self, auto_schema: AutoSchema, direction: Direction):
return build_array_type(build_basic_type(OpenApiTypes.STR)) @tfranzel suggests here that this can be also achieved with a |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I use drf-yasg to create the swagger page,but it shows that tags filed is a string.
And I tried to make a new filed by:
class MyTagListSerializerField(TagListSerializerField, serializers.ListField):
pass
and it worked. So i think is the TagListSerializerField should Inherit from serializers.ListField but not serializers.Field will be better.
Sure, it's just an immature idea. Waitting for your help!
The text was updated successfully, but these errors were encountered: