Complete backend MVP

This commit is contained in:
gabdevele
2026-06-05 11:56:28 +02:00 Unverified
parent 25c280f38b
commit 5974f01daa
25 changed files with 3468 additions and 1137 deletions
+22 -1
View File
@@ -30,10 +30,31 @@ def operation_id(controller: str, handler: str) -> str:
def openapi_path(path: str) -> tuple[str, list[dict[str, Any]]]:
parameters: list[dict[str, Any]] = []
segments = path.split("/")
placeholder_names: dict[int, str] = {}
for position, segment in enumerate(segments):
match = re.fullmatch(r"\{(\d+)\}", segment)
if not match:
continue
index = int(match.group(1))
if index == 1:
placeholder_names[index] = "id"
continue
previous = segments[position - 1] if position > 0 else ""
if previous.endswith("ies"):
stem = previous[:-3] + "y"
elif previous.endswith("s") and len(previous) > 1:
stem = previous[:-1]
else:
stem = previous or f"param{index}"
placeholder_names[index] = f"{stem}_id"
def replace(match: re.Match[str]) -> str:
index = int(match.group(1))
name = "id" if index == 1 else f"param{index}"
name = placeholder_names.get(index, f"param{index}")
parameters.append(
{
"name": name,