Handle django rest framework HiddenField (#79)

* Added HiddenFieldInspector (#78)
* Updated docs + added test for HiddenField

Added HiddenField to testproj (no change in yaml as expected)

Closes #78.
This commit is contained in:
John Carter
2018-03-10 09:46:47 +13:00
committed by Cristi Vîjdea
parent b62161f762
commit 2c459024d1
6 changed files with 27 additions and 4 deletions
+11 -1
View File
@@ -465,11 +465,21 @@ class DictFieldInspector(FieldInspector):
return NotHandled
class HiddenFieldInspector(FieldInspector):
"""Hide ``HiddenField``."""
def field_to_swagger_object(self, field, swagger_object_type, use_references, **kwargs):
if isinstance(field, serializers.HiddenField):
return None
return NotHandled
class StringDefaultFieldInspector(FieldInspector):
"""For otherwise unhandled fields, return them as plain :data:`.TYPE_STRING` objects."""
def field_to_swagger_object(self, field, swagger_object_type, use_references, **kwargs): # pragma: no cover
# TODO unhandled fields: TimeField HiddenField JSONField
# TODO unhandled fields: TimeField JSONField
SwaggerType, ChildSwaggerType = self._get_partial_types(field, swagger_object_type, use_references, **kwargs)
return SwaggerType(type=openapi.TYPE_STRING)