Describe the bug
Hi, I've changed the default list_serializer_class by an DictSerializer but I have not found a way to change the schema according it. Maybe there is some way to do it but i don't know. I tried with extension schemas, and fileds and custom serializerextensions without success.
class BrandDictSerializer(serializers.ModelSerializer)
Meta:
model = Brand
fieds = (id, name)
list_serializer_class = DictSerializer
class DictSerializer(serializers.ListSerializer):
dict_key = id
@property
def data(self):
ret = super(serializers.ListSerializer, self).data
return ReturnDict(ret, serializer=self)
def to_representation(self, data):
items = super(DictSerializer, self).to_representation(data)
return {item[self.dict_key]: item for item in items}
Expected behavior
I expect the schema get an object type with additionalProperties of type Brand
"BrandDic": {
"type": "object",
additionalProperties:
"properties": {
"id": {
"type": "integer",
"readOnly": true
},
"brand": {
"$ref": "#/components/schemas/Brand"
}
}
Describe the bug
Hi, I've changed the default list_serializer_class by an DictSerializer but I have not found a way to change the schema according it. Maybe there is some way to do it but i don't know. I tried with extension schemas, and fileds and custom serializerextensions without success.
Expected behavior
I expect the schema get an object type with additionalProperties of type Brand