Open vchepurko opened 4 years ago
Is it a way to create circular references to generate open API schema using rest_framework.serializers?
To build tree structure Serializer needs to reference for self.
class ItemSerializer(Serializer): item = serializers.SerializerMethodField() class Meta: swagger_schema_fields = item_schema @swagger_serializer_method(serializer_or_field=ItemSerializer) def get_item(self, item): return ItemSerializer(item).data def to_representation(self, item): return { "items": [self.get_item(item) for item in item.items] } class TreeSerializer(Serializer): item = serializers.SerializerMethodField() class Meta: swagger_schema_fields = tree_schema @swagger_serializer_method(serializer_or_field=ItemSerializer) def get_item(self, data): return ItemSerializer(data, markdown_to_html=self.markdown_to_html).data def to_representation(self, data): return { "items": [self.get_item(item) for item in data] }
It is incorrect code, is it exists how to correctly create tree structure for swagger?
I have similar problem. Has anyone found a solution?
Is it a way to create circular references to generate open API schema using rest_framework.serializers?
To build tree structure Serializer needs to reference for self.
It is incorrect code, is it exists how to correctly create tree structure for swagger?