Rename swagger_serializer_method parameter and update docs

This commit is contained in:
Cristi Vîjdea
2018-08-08 01:41:54 +03:00
parent afcba582b3
commit 23ebba4207
5 changed files with 49 additions and 41 deletions
+2 -2
View File
@@ -459,8 +459,8 @@ def get_basic_type_info_from_hint(hint_class):
class SerializerMethodFieldInspector(FieldInspector):
"""Provides conversion for SerializerMethodField, optionally using information from the swagger_method_field
decorator
"""Provides conversion for SerializerMethodField, optionally using information from the swagger_serializer_method
decorator.
"""
def field_to_swagger_object(self, field, swagger_object_type, use_references, **kwargs):
+3 -3
View File
@@ -178,18 +178,18 @@ def swagger_auto_schema(method=None, methods=None, auto_schema=unset, request_bo
return decorator
def swagger_serializer_method(serializer):
def swagger_serializer_method(serializer_or_field):
"""
Decorates the method of a serializers.SerializerMethodField
to hint as to how Swagger should be generated for this field.
:param serializer: serializer class or instance
:param serializer_or_field: ``Serializer``/``Field`` class or instance
:return:
"""
def decorator(serializer_method):
# stash the serializer for SerializerMethodFieldInspector to find
serializer_method._swagger_serializer = serializer
serializer_method._swagger_serializer = serializer_or_field
return serializer_method
return decorator