diff --git a/docs/changelog.rst b/docs/changelog.rst index 83886947..681e054f 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -3,6 +3,15 @@ Changelog ######### +********* +**1.4.7** +********* + +*Release date: Mar 05, 2018* + +- **FIXED:** prevent crashes caused by attempting to delete object attributes which do not exist in the first place + (:issue:`76`) + ********* **1.4.6** ********* diff --git a/src/drf_yasg/generators.py b/src/drf_yasg/generators.py index 64a74b78..272965a1 100644 --- a/src/drf_yasg/generators.py +++ b/src/drf_yasg/generators.py @@ -356,9 +356,9 @@ def get_operation(self, view, path, prefix, method, components, request): view_inspector = view_inspector_cls(view, path, method, components, request, overrides) operation = view_inspector.get_operation(operation_keys) - if set(operation.consumes) == set(self.consumes): + if 'consumes' in operation and set(operation.consumes) == set(self.consumes): del operation.consumes - if set(operation.produces) == set(self.produces): + if 'produces' in operation and set(operation.produces) == set(self.produces): del operation.produces return operation diff --git a/src/drf_yasg/inspectors/field.py b/src/drf_yasg/inspectors/field.py index 68965ae0..208b551e 100644 --- a/src/drf_yasg/inspectors/field.py +++ b/src/drf_yasg/inspectors/field.py @@ -89,9 +89,9 @@ def make_schema_definition(): properties=properties, required=required or None, ) - if not ref_name: + if not ref_name and 'title' in result: # on an inline model, the title is derived from the field name - # but is visually displayed like the model named, which is confusing + # but is visually displayed like the model name, which is confusing # it is better to just remove title from inline models del result.title return result