api docs and schema updates

This commit is contained in:
burnettk 2024-04-01 09:58:24 -04:00
parent 8b795f994e
commit 0118dc9037
No known key found for this signature in database
3 changed files with 84 additions and 7 deletions

View File

@ -0,0 +1,44 @@
# extract_functions.py
import ast
import sys
def extract_function_body(filename, function_name):
file_lines = None
with open(filename, "r") as file:
file_lines = file.read()
tree = ast.parse(file_lines, filename=filename)
# file_lines = file.readlines()
# # convert file_lines to string
# file_lines = "".join(file_lines)
# Dictionary to store function bodies
function_bodies = {}
# Find the target function and its dependencies
for node in ast.walk(tree):
if isinstance(node, ast.FunctionDef):
if node.name == function_name:
function_bodies[node.name] = ast.get_source_segment(file_lines, node)
# Extract dependencies
# for n in ast.walk(node):
# if isinstance(n, ast.Call):
# function_bodies[n.func.id] = extract_function_body(filename, n.func.id)
return function_bodies
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: python extract_functions.py <filename> <function_name>")
sys.exit(1)
filename = sys.argv[1]
function_name = sys.argv[2]
function_bodies = extract_function_body(filename, function_name)
for func_name, func_body in function_bodies.items():
print(f"Function: {func_name}")
print(func_body)
print()

View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
function error_handler() {
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
exit "$2"
}
trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail
function_name=$1
filename=$2
python spiffworkflow-backend/bin/codemod/extract_functions.py "$filename" "$function_name"
function_body=$(python spiffworkflow-backend/bin/codemod/extract_functions.py "$filename" "$function_name")
# Extract function calls and recursively extract their bodies
while IFS= read -r line; do
if [[ "$line" =~ ^Function:\ (.*)$ ]]; then
called_function="${BASH_REMATCH[1]}"
echo "$line"
echo "$function_body" | grep -q "Function: $called_function" || ./extract_functions.sh "$called_function" "$filename"
fi
done <<<"$function_body"

View File

@ -324,16 +324,26 @@ paths:
tags:
- Active User
operationId: spiffworkflow_backend.routes.active_users_controller.active_user_updates
summary: An SSE (Server Sent Events) endpoint that returns what users are also currently viewing the same page as you.
summary: An endpoint that updates the active user's last seen timestamp and returns other active users on the same page.
responses:
"200":
description: list of users
description: List of active users on the same page.
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/User"
type: object
properties:
user_id:
type: integer
description: The unique identifier of the user.
username:
type: string
description: The username of the active user.
last_seen:
type: integer
description: The last seen timestamp in seconds.
/active-users/unregister/{last_visited_identifier}:
parameters:
@ -347,10 +357,10 @@ paths:
tags:
- Active User
operationId: spiffworkflow_backend.routes.active_users_controller.active_user_unregister
summary: Unregisters a user from a page. To be used when the /active-users/updates endpoint is closed.
summary: Unregisters a user from being active on a page.
responses:
"200":
description: The current user has unregistered.
description: The current user has been successfully unregistered from the page.
content:
application/json:
schema:
@ -392,7 +402,7 @@ paths:
$ref: "#/components/schemas/ProcessGroup"
post:
operationId: spiffworkflow_backend.routes.process_groups_controller.process_group_create
summary: Add process group
summary: Creates a new process group with the provided details.
tags:
- Process Groups
requestBody:
@ -402,7 +412,7 @@ paths:
$ref: "#/components/schemas/ProcessGroup"
responses:
"201":
description: Processs Group
description: The newly created process group.
content:
application/json:
schema: