#!/usr/bin/env python3 """Export the model registry OpenAPI contract (design doc section 11 step 3). Regenerates ``EvoScientist/model_registry/openapi.json`` from the same Pydantic schemas the HTTP API validates against, so contract tests and the WebUI type generation always track the backend:: .venv/bin/python scripts/export_model_registry_schema.py """ from __future__ import annotations import json from pathlib import Path from EvoScientist.model_registry.http_api import build_openapi_document OUTPUT_PATH = ( Path(__file__).resolve().parent.parent / "EvoScientist" / "model_registry" / "openapi.json" ) def main() -> None: document = build_openapi_document() OUTPUT_PATH.write_text( json.dumps(document, indent=2, sort_keys=True) + "\n", encoding="utf-8", ) print(f"Wrote {OUTPUT_PATH}") if __name__ == "__main__": main()