File size: 769 Bytes
348eedc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""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())