Skip to content

Commit

Permalink
Merge pull request #2762 from charettes/metadata-null-boolean-field
Browse files Browse the repository at this point in the history
Metadata should detect null boolean field type.
  • Loading branch information
xordoquy committed Mar 25, 2015
2 parents 197027c + 8720802 commit ac77a56
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions rest_framework/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class SimpleMetadata(BaseMetadata):
label_lookup = ClassLookupDict({
serializers.Field: 'field',
serializers.BooleanField: 'boolean',
serializers.NullBooleanField: 'boolean',
serializers.CharField: 'string',
serializers.URLField: 'url',
serializers.EmailField: 'email',
Expand Down
7 changes: 6 additions & 1 deletion tests/test_metadata.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from __future__ import unicode_literals
from rest_framework import exceptions, serializers, status, views, versioning
from rest_framework import exceptions, metadata, serializers, status, views, versioning
from rest_framework.request import Request
from rest_framework.renderers import BrowsableAPIRenderer
from rest_framework.test import APIRequestFactory
Expand Down Expand Up @@ -207,3 +207,8 @@ def get_serializer(self):
scheme = versioning.QueryParameterVersioning
view = ExampleView.as_view(versioning_class=scheme)
view(request=request)

def test_null_boolean_field_info_type(self):
options = metadata.SimpleMetadata()
field_info = options.get_field_info(serializers.NullBooleanField())
assert field_info['type'] == 'boolean'

0 comments on commit ac77a56

Please sign in to comment.