feat(api): generate unique readable OpenAPI operationIds

This commit is contained in:
Mark Paronyan committed 2026-10-07 15:53:00 +03:00
1 parent 2fb7056cb9
commit 6ed9e44f00
5 files changed
+149 -4

No files matched your search

@@ -21,6 +21,7 @@ from fastapi import Depends, FastAPI, Request
from fastapi.responses import JSONResponse
from starlette.exceptions import HTTPException as StarletteHTTPException
from gns3server.api.operation_ids import generate_operation_id
from gns3server.compute.compute_error import (
ComputeError,
ComputeForbiddenError,
@@ -61,6 +62,7 @@ compute_api = FastAPI(
title="GNS3 compute API",
description="This page describes the private compute API for GNS3. PLEASE DO NOT USE DIRECTLY!",
version="3.0.0",
generate_unique_id_function=generate_operation_id,
)
compute_api.state.controller_host = None
+5 -3
View File
@@ -18,6 +18,7 @@ from fastapi import APIRouter, Depends, HTTPException, status
# Check AI Copilot availability
from gns3server.agent import AI_COPILOT_AVAILABLE
from gns3server.api.operation_ids import add_stub_routes
# Conditionally import AI-dependent routes
if AI_COPILOT_AVAILABLE:
@@ -32,15 +33,16 @@ else:
_copilot_router = APIRouter()
_llm_router = APIRouter()
@_chat_router.api_route("/{path:path}", methods=["GET", "POST", "DELETE", "PATCH", "PUT"])
@_copilot_router.api_route("/{path:path}", methods=["GET", "POST", "DELETE", "PATCH", "PUT"])
@_llm_router.api_route("/{path:path}", methods=["GET", "POST", "DELETE", "PATCH", "PUT"])
async def ai_not_available(path: str = ""):
raise HTTPException(
status_code=status.HTTP_501_NOT_IMPLEMENTED,
detail="AI Copilot is not available. Install AI dependencies with: pip install gns3-server[ai-features]",
)
add_stub_routes(_chat_router, ai_not_available, "chat_not_available")
add_stub_routes(_copilot_router, ai_not_available, "copilot_not_available")
add_stub_routes(_llm_router, ai_not_available, "llm_not_available")
from . import (
acl,