Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.
TypeScript ai-artartificial-intelligencegenerative-artimage-generationimg2imginpaintinglatent-diffusionlinuxmacosoutpaintingstable-diffusiontxt2imgwindows
fix(openapi): normalize Path defaults to POSIX in schema generation (#9209)
Alexander Eichhorn0963bb6b0d2f
diff --git a/invokeai/app/util/custom_openapi.py b/invokeai/app/util/custom_openapi.pyindex fd89fe2cc0..f674fa7621 100644--- a/invokeai/app/util/custom_openapi.py+++ b/invokeai/app/util/custom_openapi.py@@ -30,6 +30,23 @@ def move_defs_to_top_level(openapi_schema: dict[str, Any], component_schema: dicopenapi_schema["components"]["schemas"][schema_key] = json_schema+def normalize_path_defaults(node: Any) -> None:+ """Recursively normalize `default` strings on schema nodes whose `format` is `path` to use forward slashes.++ Pydantic stringifies `Path` defaults using the host OS's separator, so a default declared as+ `Path("models/.convert_cache")` serializes to `models\\.convert_cache` on Windows. That OS-dependent drift+ pollutes diffs whenever schema is regenerated on Windows. We force POSIX form for path-typed defaults.+ """+ if isinstance(node, dict):+ if node.get("format") == "path" and isinstance(node.get("default"), str):+ node["default"] = node["default"].replace("\\", "/")+ for v in node.values():+ normalize_path_defaults(v)+ elif isinstance(node, list):+ for v in node:+ normalize_path_defaults(v)++def get_openapi_func(app: FastAPI, post_transform: Optional[Callable[[dict[str, Any]], dict[str, Any]]] = None) -> Callable[[], dict[str, Any]]:@@ -126,6 +143,8 @@ def get_openapi_func(if post_transform is not None:openapi_schema = post_transform(openapi_schema)+ normalize_path_defaults(openapi_schema)+openapi_schema["components"]["schemas"] = dict(sorted(openapi_schema["components"]["schemas"].items()))app.openapi_schema = openapi_schema