-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathcommon.py
More file actions
36 lines (31 loc) · 1.28 KB
/
common.py
File metadata and controls
36 lines (31 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
def organize_spec(paths, scopes):
operations = list() # list of operation IDs
for path, methods in paths.items():
# method is the HTTP action, e.g., get, put, etc.
for method in methods:
# endpoint is the method for that specific path
endpoint = paths[path][method]
# the endpoint has tags
tags = endpoint["tags"]
# the endpoint has an operationId
operation = endpoint["operationId"]
# add the operation ID to the list
operations.append(operation)
# The endpoint has a scope defined by the first tag
# There are a handful of operations that are currently mistagged
# This helps ensure they are scoped to the correct module
if len(tags) > 2:
match tags[2]:
case 'spaces':
scope = 'spaces'
case _:
scope = tags[0]
else:
scope = tags[0]
# Needs documentation
if path not in scopes[scope]:
scopes[scope][path] = {method: endpoint}
# Needs documentation
else:
scopes[scope][path][method] = endpoint
return operations, scopes