Skip HiddenField from Schema fields (#4429)

This commit is contained in:
José Padilla 2016-08-22 11:53:53 -04:00 committed by Tom Christie
parent d540f0262b
commit d0ed482d70
2 changed files with 4 additions and 1 deletions

View File

@ -296,8 +296,9 @@ class SchemaGenerator(object):
fields = [] fields = []
for field in serializer.fields.values(): for field in serializer.fields.values():
if field.read_only: if field.read_only or isinstance(field, serializers.HiddenField):
continue continue
required = field.required and method != 'PATCH' required = field.required and method != 'PATCH'
description = force_text(field.help_text) if field.help_text else '' description = force_text(field.help_text) if field.help_text else ''
field = coreapi.Field( field = coreapi.Field(

View File

@ -26,6 +26,8 @@ class ExamplePagination(pagination.PageNumberPagination):
class ExampleSerializer(serializers.Serializer): class ExampleSerializer(serializers.Serializer):
a = serializers.CharField(required=True, help_text='A field description') a = serializers.CharField(required=True, help_text='A field description')
b = serializers.CharField(required=False) b = serializers.CharField(required=False)
read_only = serializers.CharField(read_only=True)
hidden = serializers.HiddenField(default='hello')
class AnotherSerializer(serializers.Serializer): class AnotherSerializer(serializers.Serializer):