import json from type import OpenAPI PATHS: list[str] = [] PREFIX = "/api" TOP_COMMENT = """\"\"\" ======================= WARNING ======================= This file is automatically generated by compiler/endpoints.py. If this file is modified and then auto-generated, the changes will be lost. \"\"\"\n """ IMPORTS = "from typing import Literal\n\n" TEMPLATES = "ENDPOINTS = " with open("./datas/v13_api.json", mode="r", encoding="utf-8") as f: api: OpenAPI = json.load(f) for path in api["paths"]: PATHS.append(f"{PREFIX}{path}") with open("../mipac/types/endpoints.py", "w", encoding="utf-8") as f: data = json.dumps(PATHS, ensure_ascii=False, indent=4) f.write(f"{TOP_COMMENT}{IMPORTS}{TEMPLATES}Literal{data}\n")