Coverage for backend/django/diagnostics/schemas.py: 100%
18 statements
« prev ^ index » next coverage.py v7.10.7, created at 2026-03-26 20:57 +0000
« prev ^ index » next coverage.py v7.10.7, created at 2026-03-26 20:57 +0000
1"""
2Shared Pydantic schemas for the diagnostics module.
4These models define the JSON finding shapes we return to the frontend.
5Keeping them here avoids drifting "finding" definitions across:
6- rules engine output (RuleFinding)
7"""
9from __future__ import annotations
11from typing import Literal
13from pydantic import BaseModel, JsonValue
15# Severity levels expected by the frontend.
16Severity = Literal["error", "warning", "info", "suggestion"]
19class DiagnosticsFinding(BaseModel):
20 """
21 A single diagnostics finding in the shape the UI expects.
23 Notes:
24 - This is intentionally permissive: different finding sources attach different
26 """
28 id: str | None = None
29 severity: Severity = "info"
30 title: str
31 description: str
32 ruleReference: str | None = None
34 componentName: str | None = None
35 componentId: int | None = None
36 propertyKey: str | None = None
37 propertyId: int | None = None
39 suggestedFix: str | None = None
40 suggestedValue: float | None = None
41 fixAction: JsonValue | None = None
43 ignored: bool | None = None