Only set 'encoding' if a 'form' or 'body' field exists

This commit is contained in:
Tom Christie 2016-06-22 14:20:05 +01:00
parent 2f5c9748d3
commit e78753dd0c

View File

@ -197,7 +197,7 @@ class SchemaGenerator(object):
fields += self.get_pagination_fields(path, method, callback, view)
fields += self.get_filter_fields(path, method, callback, view)
if fields:
if fields and any([field.location in ('form', 'body') for field in fields]):
encoding = self.get_encoding(path, method, callback, view)
else:
encoding = None
@ -213,9 +213,6 @@ class SchemaGenerator(object):
"""
Return the 'encoding' parameter to use for a given endpoint.
"""
if method not in set(('POST', 'PUT', 'PATCH')):
return None
# Core API supports the following request encodings over HTTP...
supported_media_types = set((
'application/json',