From 69aaa71c979d290422f928e5b45eb51455933ad5 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Mon, 2 Jan 2023 20:41:21 +0100 Subject: [PATCH] Improve checkAPI.py script (add handling of {kind} URI variables) Signed-off-by: DL6ER --- test/api/checkAPI.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/test/api/checkAPI.py b/test/api/checkAPI.py index 80746862..6fb5006e 100644 --- a/test/api/checkAPI.py +++ b/test/api/checkAPI.py @@ -10,10 +10,12 @@ base_path = "src/api/docs/content/specs/" # List of methods we want to extract methods = ["get", "post", "put", "delete"] -# Prepare list of endpoints -endpoints = {} +API_ROOT = "/api" + +# Prepare list of YAML endpoints +YAMLendpoints = {} for method in methods: - endpoints[method] = [] + YAMLendpoints[method] = [] # Cache for already read files yamls = {} @@ -83,10 +85,14 @@ print("Resolving references...") recurseRef(paths, "") print("...done\n") -# Sort the list of endpoints -YAMLendpoints = {} +# Build and sort the list of endpoints 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 try: