mirror of
https://github.com/mgeeky/decode-spam-headers.git
synced 2026-02-22 05:23:31 +01:00
MAESTRO: add tests endpoint schema
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
from fastapi import FastAPI
|
||||
|
||||
from app.routers.tests import router as tests_router
|
||||
|
||||
app = FastAPI(title="Web Header Analyzer API")
|
||||
app.include_router(tests_router)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
|
||||
1
backend/app/routers/__init__.py
Normal file
1
backend/app/routers/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""FastAPI routers."""
|
||||
15
backend/app/routers/tests.py
Normal file
15
backend/app/routers/tests.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.engine.scanner_registry import ScannerRegistry
|
||||
from app.schemas.tests import TestResponse
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["tests"])
|
||||
|
||||
|
||||
@router.get("/tests", response_model=list[TestResponse])
|
||||
def list_tests() -> list[TestResponse]:
|
||||
registry = ScannerRegistry()
|
||||
tests = registry.list_tests()
|
||||
return [TestResponse.model_validate(test) for test in tests]
|
||||
1
backend/app/schemas/__init__.py
Normal file
1
backend/app/schemas/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
"""API response schemas."""
|
||||
7
backend/app/schemas/tests.py
Normal file
7
backend/app/schemas/tests.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from app.engine.models import Test
|
||||
|
||||
|
||||
class TestResponse(Test):
|
||||
pass
|
||||
Reference in New Issue
Block a user