forked from ChelseaKR/ceqa-preflight
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema_export.py
More file actions
28 lines (20 loc) · 838 Bytes
/
Copy pathschema_export.py
File metadata and controls
28 lines (20 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""Export machine-readable public schemas from the typed contracts."""
from __future__ import annotations
import json
from pathlib import Path
from ceqa_preflight.models import InspectionReport, PackageManifest
def export_schemas(destination: Path) -> None:
"""Write stable JSON schema artifacts to an explicitly supplied directory."""
destination.mkdir(parents=True, exist_ok=True)
artifacts = {
"manifest.schema.json": PackageManifest.model_json_schema(),
"report.schema.json": InspectionReport.model_json_schema(),
}
for filename, schema in artifacts.items():
path = destination / filename
path.write_text(
json.dumps(schema, indent=2, sort_keys=True) + "\n",
encoding="utf-8",
)
if __name__ == "__main__":
export_schemas(Path("schemas"))