Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
KissPeter committed Feb 7, 2021
2 parents ccc4f5d + e609a1c commit f9cb9cf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions apifuzzer/move_json_parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@


class JsonSectionAbove:
"""
By organizing the API definition OpenAPI v3 and Swagger v2 API definitions can be processed in a similar way
"""

def __init__(self, api_definition, section_to_up='schema'):
self.logger = get_logger(f'{self.__class__.__name__}-{section_to_up}')
Expand All @@ -28,9 +31,9 @@ def _resolve(self, data):
elif isinstance(value, list):
if not return_data.get(key):
return_data[key] = list()
for _iter in range(len(value)):
for _iter, val in enumerate(value):
self.logger.debug(f'Process {key} list elem: {_iter}')
return_data[key].append(self.resolve(data=value[_iter]))
return_data[key].append(self.resolve(data=val))

else:
return_data[key] = value
Expand Down
5 changes: 4 additions & 1 deletion apifuzzer/resolve_json_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ class FailedToResolveReference(Exception):


class ResolveReferences:
"""
Resolve API references in order to get one single JSON object with all data available in place
"""

def __init__(self, api_definition_path=None, api_definition_url=""):
self.logger = get_logger(self.__class__.__name__)
Expand Down Expand Up @@ -156,7 +159,7 @@ def _resolve(self, data):
elif isinstance(value, list):
if not return_data.get(key):
return_data[key] = list()
for _iter in range(len(value)):
for _iter, _ in enumerate(value):
self.logger.debug(f'Process {key} list elem: {_iter}')
return_data[key].append(self.resolve(data=data[key][_iter]))
elif key == '$ref' and value:
Expand Down

0 comments on commit f9cb9cf

Please sign in to comment.