From f43517b9a51f36e16d1df290fb42d9e1178c1be2 Mon Sep 17 00:00:00 2001 From: Adam Outler Date: Mon, 2 Feb 2026 23:14:45 +0100 Subject: [PATCH] chore(api): Cleanup schemas and update skills docs --- .gemini/skills/testing-workflow/SKILL.md | 21 ++++++++++++++++----- server/api_server/openapi/schemas.py | 21 +++++++++++++++++++-- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/.gemini/skills/testing-workflow/SKILL.md b/.gemini/skills/testing-workflow/SKILL.md index a496bfd7..6a49b6fa 100644 --- a/.gemini/skills/testing-workflow/SKILL.md +++ b/.gemini/skills/testing-workflow/SKILL.md @@ -51,13 +51,24 @@ cd /workspaces/NetAlertX; pytest test/ cd /workspaces/NetAlertX; pytest test/api_endpoints/test_mcp_extended_endpoints.py ``` -## Authentication in Tests +## Authentication & Environment Reset -The test environment uses `API_TOKEN`. The most reliable way to retrieve the current token from a running container is: +Authentication tokens are required to perform certain operations such as manual testing or crafting expressions to work with the web APIs.After making code changes, you MUST reset the environment to ensure the new code is running and verify you have the latest `API_TOKEN`. -```bash -python3 -c "from helper import get_setting_value; print(get_setting_value('API_TOKEN'))" -``` +1. **Reset Environment:** Run the setup script inside the container. + ```bash + bash /workspaces/NetAlertX/.devcontainer/scripts/setup.sh + ``` +2. **Wait for Stabilization:** Wait at least 5 seconds for services (nginx, python server, etc.) to start. + ```bash + sleep 5 + ``` +3. **Obtain Token:** Retrieve the current token from the container. + ```bash + python3 -c "from helper import get_setting_value; print(get_setting_value('API_TOKEN'))" + ``` + +The retrieved token MUST be used in all subsequent API or test calls requiring authentication. ### Troubleshooting diff --git a/server/api_server/openapi/schemas.py b/server/api_server/openapi/schemas.py index 96f862de..5181a4b7 100644 --- a/server/api_server/openapi/schemas.py +++ b/server/api_server/openapi/schemas.py @@ -39,8 +39,7 @@ ALLOWED_DEVICE_COLUMNS = Literal[ ] ALLOWED_NMAP_MODES = Literal[ - "quick", "intense", "ping", "comprehensive", "fast", "normal", "detail", "skipdiscovery", - "-sS", "-sT", "-sU", "-sV", "-O" + "fast", "normal", "detail", "skipdiscovery" ] NOTIFICATION_LEVELS = Literal["info", "warning", "error", "alert", "interrupt"] @@ -301,6 +300,24 @@ class DeviceTotalsResponse(RootModel): root: List[int] = Field(default_factory=list, description="List of counts: [all, online, favorites, new, offline, archived]") +class DeviceTotalsNamedResponse(BaseResponse): + """Response with named device statistics.""" + totals: Dict[str, int] = Field( + ..., + description="Dictionary of counts", + json_schema_extra={ + "examples": [{ + "devices": 10, + "connected": 5, + "favorites": 2, + "new": 1, + "down": 0, + "archived": 2 + }] + } + ) + + class DeviceExportRequest(BaseModel): """Request for exporting devices.""" format: Literal["csv", "json"] = Field(