mirror of
https://github.com/pi-hole/FTL.git
synced 2025-12-24 12:08:24 +00:00
Improve checkAPI.py script (add handling of {kind} URI variables)
Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
@@ -10,10 +10,12 @@ base_path = "src/api/docs/content/specs/"
|
|||||||
# List of methods we want to extract
|
# List of methods we want to extract
|
||||||
methods = ["get", "post", "put", "delete"]
|
methods = ["get", "post", "put", "delete"]
|
||||||
|
|
||||||
# Prepare list of endpoints
|
API_ROOT = "/api"
|
||||||
endpoints = {}
|
|
||||||
|
# Prepare list of YAML endpoints
|
||||||
|
YAMLendpoints = {}
|
||||||
for method in methods:
|
for method in methods:
|
||||||
endpoints[method] = []
|
YAMLendpoints[method] = []
|
||||||
|
|
||||||
# Cache for already read files
|
# Cache for already read files
|
||||||
yamls = {}
|
yamls = {}
|
||||||
@@ -83,10 +85,14 @@ print("Resolving references...")
|
|||||||
recurseRef(paths, "")
|
recurseRef(paths, "")
|
||||||
print("...done\n")
|
print("...done\n")
|
||||||
|
|
||||||
# Sort the list of endpoints
|
# Build and sort the list of endpoints
|
||||||
YAMLendpoints = {}
|
|
||||||
for method in methods:
|
for method in methods:
|
||||||
YAMLendpoints[method] = sorted(endpoints[method])
|
for path in paths:
|
||||||
|
if method in paths[path]:
|
||||||
|
# Strip possible variables from path
|
||||||
|
clean_path = API_ROOT + path.partition("/{")[0]
|
||||||
|
YAMLendpoints[method].append(clean_path)
|
||||||
|
YAMLendpoints[method] = sorted(YAMLendpoints[method])
|
||||||
|
|
||||||
# Query the endpoints from FTL for comparison with the OpenAPI specs
|
# Query the endpoints from FTL for comparison with the OpenAPI specs
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user