Guard against attempted deletion of inexistent attributes

Fixes #76
openapi3 1.4.7
Cristi Vîjdea 2018-03-05 19:59:03 +02:00
parent 3d3b7899e5
commit 9ad55bac99
3 changed files with 13 additions and 4 deletions

View File

@ -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** **1.4.6**
********* *********

View File

@ -356,9 +356,9 @@ class OpenAPISchemaGenerator(object):
view_inspector = view_inspector_cls(view, path, method, components, request, overrides) view_inspector = view_inspector_cls(view, path, method, components, request, overrides)
operation = view_inspector.get_operation(operation_keys) 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 del operation.consumes
if set(operation.produces) == set(self.produces): if 'produces' in operation and set(operation.produces) == set(self.produces):
del operation.produces del operation.produces
return operation return operation

View File

@ -89,9 +89,9 @@ class InlineSerializerInspector(SerializerInspector):
properties=properties, properties=properties,
required=required or None, 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 # 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 # it is better to just remove title from inline models
del result.title del result.title
return result return result