"""Print the API's OpenAPI JSON (used by web/scripts/gen-api.mjs and the drift test). Uses a throwaway FPT_HOME.""" from __future__ import annotations import json import sys def openapi_json() -> str: from ..tests.fakes import temp_settings from .app import create_app from ..graph.services import build_services import logging before = logging.root.manager.disable # restored after: a caller in the same process (the test run) keeps its logs logging.disable(logging.CRITICAL) try: app = create_app(build_services(temp_settings()), background=False) return json.dumps(app.openapi(), indent=1, sort_keys=True) finally: logging.disable(before) if __name__ == "__main__": sys.stdout.write(openapi_json())