Avoid crash when hitting unknown model fields

Fixes #102
openapi3
Cristi Vîjdea 2018-04-25 22:41:06 +03:00
parent 5e684549a1
commit c0f37f6ec1
1 changed files with 3 additions and 1 deletions

View File

@ -410,7 +410,9 @@ class ChoiceFieldInspector(FieldInspector):
model = getattr(getattr(serializer, 'Meta'), 'model') model = getattr(getattr(serializer, 'Meta'), 'model')
model_field = get_model_field(model, field.source) model_field = get_model_field(model, field.source)
if model_field: if model_field:
enum_type = get_basic_type_info(model_field).get('type', enum_type) model_type = get_basic_type_info(model_field)
if model_type:
enum_type = model_type.get('type', enum_type)
if isinstance(field, serializers.MultipleChoiceField): if isinstance(field, serializers.MultipleChoiceField):
return SwaggerType( return SwaggerType(