From 9e8d12c970dc24965e3363902051cf9d0e85618d Mon Sep 17 00:00:00 2001 From: Salih Karakaya <32556786+KarakayaFSM@users.noreply.github.com> Date: Thu, 4 Feb 2021 23:31:03 +0300 Subject: [PATCH] Replaced javascript like dict key checks Replaced javascript like if['dict'] key checks with in operator to prevent null pointers. --- postdown/parser.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/postdown/parser.py b/postdown/parser.py index 1e718d7..8c71ee1 100644 --- a/postdown/parser.py +++ b/postdown/parser.py @@ -57,7 +57,7 @@ def parse_api(doc, api): doc.table(['Key', 'Value', 'Description'], rows) # Request Header - if request['header']: + if 'header' in request: doc.bold('Header') rows = get_rows( request['header'], @@ -125,7 +125,7 @@ def parse_api(doc, api): doc.table(['Key', 'Value', 'Description'], rows) # Request Header - if request['header']: + if 'header' in request: doc.bold('Header') rows = get_rows( request['header'], @@ -159,7 +159,7 @@ def parse_api(doc, api): doc.comment_end('Request Query') doc.hr() - if response['body']: + if 'body' in response: doc.bold('Response') logger.info('Example Response') #logger.debug('response body: % s', response['body']) @@ -211,4 +211,4 @@ def parse(in_file, out_file): parse_api(doc, folder) with open(out_file, 'w+') as f: - f.write(doc.output()) \ No newline at end of file + f.write(doc.output())