Skip to content

Commit

Permalink
fix(ingest): handle endpoints without 200 response in openapi (#4332)
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgenEvens authored Mar 15, 2022
1 parent 50ef658 commit af5c4ee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,14 @@ def get_endpoints(sw_dict: dict) -> dict: # noqa: C901
# will track only the "get" methods, which are the ones that give us data
if "get" in p_o.keys():

try:
if "200" in p_o["get"]["responses"].keys():
base_res = p_o["get"]["responses"]["200"]
except KeyError: # if you read a plain yml file the 200 will be an integer
elif 200 in p_o["get"]["responses"].keys():
# if you read a plain yml file the 200 will be an integer
base_res = p_o["get"]["responses"][200]
else:
# the endpoint does not have a 200 response
continue

if "description" in p_o["get"].keys():
desc = p_o["get"]["description"]
Expand Down
7 changes: 7 additions & 0 deletions metadata-ingestion/tests/unit/test_openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ class TestGetEndpoints(unittest.TestCase):
}
]
}
/redirect:
get:
operationId: redirectSomewhere
summary: Redirect to a different endpoint
responses:
'302':
description: 302 response
/v2:
get:
operationId: getVersionDetailsv2
Expand Down

0 comments on commit af5c4ee

Please sign in to comment.