From 818a3e4279ad8770845b74e8cf55d49ff7d75f50 Mon Sep 17 00:00:00 2001 From: PengfeiLi0218 Date: Fri, 4 Jan 2019 21:41:17 +0800 Subject: [PATCH] solve an exception that occurs when no field is in swagger --- apitester/runtests/views.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apitester/runtests/views.py b/apitester/runtests/views.py index c78ac32..1f05256 100644 --- a/apitester/runtests/views.py +++ b/apitester/runtests/views.py @@ -113,7 +113,10 @@ def get_post_or_update(self, method, testconfigs, testconfig_pk, path, data, swa if field in field_names: request_body[field] = getattr(testconfigs["selected"], field) else: - request_body[field] = params["properties"][field].get("example", "") + try: + request_body[field] = params["properties"][field].get("example", "") + except: + request_body[field] = None params = json.dumps(request_body, indent=4) return [{