@@ -57,6 +57,12 @@ def to_internal_value(self, data):
57
57
58
58
59
59
class SparseFieldsetsMixin (object ):
60
+ """
61
+ A serializer mixin that adds support for sparse fieldsets through `fields` query parameter.
62
+
63
+ Specification: https://jsonapi.org/format/#fetching-sparse-fieldsets
64
+ """
65
+
60
66
def __init__ (self , * args , ** kwargs ):
61
67
super (SparseFieldsetsMixin , self ).__init__ (* args , ** kwargs )
62
68
context = kwargs .get ('context' )
@@ -85,6 +91,13 @@ def __init__(self, *args, **kwargs):
85
91
86
92
87
93
class IncludedResourcesValidationMixin (object ):
94
+ """
95
+ A serializer mixin that adds validation of `include` query parameter to
96
+ support compound documents.
97
+
98
+ Specification: https://jsonapi.org/format/#document-compound-documents)
99
+ """
100
+
88
101
def __init__ (self , * args , ** kwargs ):
89
102
context = kwargs .get ('context' )
90
103
request = context .get ('request' ) if context else None
@@ -147,6 +160,20 @@ class Serializer(
147
160
IncludedResourcesValidationMixin , SparseFieldsetsMixin , Serializer ,
148
161
metaclass = SerializerMetaclass
149
162
):
163
+ """
164
+ A `Serializer` is a model-less serializer class with additional
165
+ support for json:api spec features.
166
+
167
+ As in json:api specification a type is always required you need to
168
+ make sure that you define `resource_name` in your `Meta` class
169
+ when deriving from this class.
170
+
171
+ Included Mixins:
172
+
173
+ * A mixin class to enable sparse fieldsets is included
174
+ * A mixin class to enable validation of included resources is included
175
+ """
176
+
150
177
pass
151
178
152
179
0 commit comments