mirror of
https://github.com/mgeeky/decode-spam-headers.git
synced 2026-02-22 13:33:30 +01:00
MAESTRO: align tests API response with selector
This commit is contained in:
@@ -3,13 +3,14 @@ from __future__ import annotations
|
||||
from fastapi import APIRouter
|
||||
|
||||
from app.engine.scanner_registry import ScannerRegistry
|
||||
from app.schemas.tests import TestResponse
|
||||
from app.schemas.tests import TestListResponse, TestResponse
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["tests"])
|
||||
|
||||
|
||||
@router.get("/tests", response_model=list[TestResponse])
|
||||
def list_tests() -> list[TestResponse]:
|
||||
@router.get("/tests", response_model=TestListResponse)
|
||||
def list_tests() -> TestListResponse:
|
||||
registry = ScannerRegistry()
|
||||
tests = registry.list_tests()
|
||||
return [TestResponse.model_validate(test.model_dump()) for test in tests]
|
||||
response_tests = [TestResponse.model_validate(test.model_dump()) for test in tests]
|
||||
return TestListResponse(tests=response_tests, total_count=len(response_tests))
|
||||
|
||||
@@ -1,7 +1,16 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
from app.engine.models import Test
|
||||
|
||||
|
||||
class TestResponse(Test):
|
||||
pass
|
||||
|
||||
|
||||
class TestListResponse(BaseModel):
|
||||
model_config = ConfigDict(populate_by_name=True)
|
||||
|
||||
tests: list[TestResponse]
|
||||
total_count: int = Field(alias="totalCount")
|
||||
|
||||
Reference in New Issue
Block a user