Skip to content

Commit 73e4af2

Browse files
committed
Serializer docstrings
1 parent 57a27dd commit 73e4af2

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

readthedocs/api/v3/serializers.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,13 @@ def _absolute_url(self, path):
3232
return urllib.parse.urlunparse((scheme, domain, path, '', '', ''))
3333

3434

35-
class BuildTriggerSerializer(serializers.ModelSerializer):
35+
class BuildCreateSerializer(serializers.ModelSerializer):
36+
37+
"""
38+
Used when triggering (create action) a ``Build`` for a specific ``Version``.
39+
40+
This serializer validates that no field is sent at all in the request.
41+
"""
3642

3743
class Meta:
3844
model = Build
@@ -76,6 +82,15 @@ def get_project(self, obj):
7682

7783
class BuildConfigSerializer(FlexFieldsSerializerMixin, serializers.Serializer):
7884

85+
"""
86+
Render ``Build.config`` property without modifying it.
87+
88+
.. note::
89+
90+
Any change on the output of that property will be reflected here,
91+
which may produce incompatible changes in the API.
92+
"""
93+
7994
def to_representation(self, obj):
8095
# For now, we want to return the ``config`` object as it is without
8196
# manipulating it.
@@ -231,6 +246,12 @@ def get_downloads(self, obj):
231246

232247
class VersionUpdateSerializer(serializers.ModelSerializer):
233248

249+
"""
250+
Used when modifying (update action) a ``Version``.
251+
252+
It only allows to make the Version active/non-active and private/public.
253+
"""
254+
234255
class Meta:
235256
model = Version
236257
fields = [

readthedocs/api/v3/views.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from .renderer import AlphabeticalSortedJSONRenderer
3232
from .serializers import (
3333
BuildSerializer,
34-
BuildTriggerSerializer,
34+
BuildCreateSerializer,
3535
ProjectSerializer,
3636
UserSerializer,
3737
VersionSerializer,
@@ -252,7 +252,7 @@ class BuildsViewSet(APIv3Settings, APIAuthMixin, NestedViewSetMixin,
252252
def get_serializer_class(self):
253253
if self.action in ('list', 'retrieve'):
254254
return BuildSerializer
255-
return BuildTriggerSerializer
255+
return BuildCreateSerializer
256256

257257
def create(self, request, **kwargs):
258258
parent_lookup_project__slug = kwargs.get('parent_lookup_project__slug')

0 commit comments

Comments
 (0)