32 lines
824 B
Python
32 lines
824 B
Python
"""Generate the checked-in API contract from the FastAPI application."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import yaml
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
sys.path.insert(0, str(ROOT / "backend"))
|
|
|
|
from app.main import app # noqa: E402
|
|
|
|
|
|
def main() -> None:
|
|
schema = app.openapi()
|
|
schema["info"]["description"] = (
|
|
"Generated contract for Fleet Ops. The visible product name is Fleet Ops; "
|
|
"MobilityOps remains the technical repository and service identifier."
|
|
)
|
|
schema["servers"] = [{"url": "http://localhost:8128"}]
|
|
output = ROOT / "contracts" / "openapi.yaml"
|
|
output.write_text(
|
|
yaml.safe_dump(schema, sort_keys=False, allow_unicode=True, width=100),
|
|
encoding="utf-8",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|