mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-23 22:34:35 +02:00
fix(api): keep the LLM stub from shadowing /access routes without AI extras
Without the AI dependencies the LLM model configuration router is replaced
by a stub that answers 501. It was a catch-all ("/{path:path}") included
under the /access prefix, so it also answered every /access route included
after it: creating an API key (POST /v3/access/api-keys) failed with "AI
Copilot is not available", which left API keys unusable on servers without
the AI extras.
The LLM stub now covers only the LLM model configuration paths, under
/access/users/{user_id}/ and /access/groups/{group_id}/. The stub routers
are built by build_ai_stub_routers() so tests can check them with or
without the extras, and add_stub_routes() takes the paths to stub.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ac01ee6190
commit
09b8420354
3 files changed
+117
-24
No files matched your search
@@ -20,7 +20,7 @@ Readable and unique OpenAPI operationIds.
|
||||
"""
|
||||
|
||||
import re
|
||||
from typing import Callable
|
||||
from typing import Callable, Sequence
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi.routing import APIRoute
|
||||
@@ -46,10 +46,13 @@ def generate_operation_id(route: APIRoute) -> str:
|
||||
return name
|
||||
|
||||
|
||||
def add_stub_routes(router: APIRouter, endpoint: Callable, name: str) -> None:
|
||||
def add_stub_routes(router: APIRouter, endpoint: Callable, name: str, paths: Sequence[str] = ("/{path:path}",)) -> None:
|
||||
"""
|
||||
Registers a catch-all route per HTTP method so that every method gets its own operationId.
|
||||
Registers a stub route per path and HTTP method so that every method gets its own operationId.
|
||||
The default path is a catch-all for everything under the router prefix.
|
||||
"""
|
||||
|
||||
for method in STUB_METHODS:
|
||||
router.add_api_route("/{path:path}", endpoint, methods=[method], name=f"{name}_{method.lower()}")
|
||||
for index, path in enumerate(paths):
|
||||
suffix = f"_{index}" if len(paths) > 1 else ""
|
||||
for method in STUB_METHODS:
|
||||
router.add_api_route(path, endpoint, methods=[method], name=f"{name}{suffix}_{method.lower()}")
|
||||
Reference in new issue
Block a user