From 416f2172368ec9bfcf0902b98330e613d8087577 Mon Sep 17 00:00:00 2001 From: Phil Krylov Date: Sun, 13 Aug 2017 23:37:22 +0300 Subject: [PATCH] Stable/0.3.x: Schema object's `required` field cannot be an empty array --- rest_framework_swagger/docgenerator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/rest_framework_swagger/docgenerator.py b/rest_framework_swagger/docgenerator.py index f83174b0..b90c4bc6 100644 --- a/rest_framework_swagger/docgenerator.py +++ b/rest_framework_swagger/docgenerator.py @@ -165,6 +165,8 @@ def get_models(self, apis): 'required': [i for i in data['required'] if i in w_properties.keys()], 'properties': w_properties, } + if not models[w_name]['required']: + del models[w_name]['required'] # Reading # no write_only fields @@ -178,6 +180,8 @@ def get_models(self, apis): 'required': [i for i in r_properties.keys()], 'properties': r_properties, } + if not models[r_name]['required']: + del models[r_name]['required'] # Enable original model for testing purposes # models[serializer_name] = {