Add ability to set Schema fields through the serializer Meta class (#134)

* Add swagger_schema_fields attribute to serializer Meta class
* Add documentation

Closes #132.
This commit is contained in:
Cristi Vîjdea authored and GitHub committed 2018-05-31 00:15:21 +03:00
1 parent cc90bc1544
commit 256a052564
5 files changed
+70 -4

No files matched your search

+11
View File
@@ -1,3 +1,5 @@
from collections import OrderedDict
from django.utils import timezone
from rest_framework import serializers
from rest_framework_recursive.fields import RecursiveField
@@ -26,6 +28,15 @@ class TodoYetAnotherSerializer(serializers.ModelSerializer):
model = TodoYetAnother
fields = ('title', 'todo')
depth = 2
swagger_schema_fields = {
'example': OrderedDict([
('title', 'parent'),
('todo', OrderedDict([
('title', 'child'),
('todo', None),
])),
])
}
class TodoTreeSerializer(serializers.ModelSerializer):