Skip to content

Commit 64bb005

Browse files
peterschmidt85Andrey Cheptsovclaude
authored
Fix docs OpenAPI spec generation for render_swagger compatibility (#3729)
Replace mkdocs_gen_files.open() with direct file writes so that render_swagger can find the JSON files on the real filesystem. Also fix the rest plugin output path (rest_plugin/ -> rest/) and remove the committed openapi.json in favor of always generating it. Skip writing when content is unchanged to avoid livereload loops. Fixes #3724 Fixes #3725 Co-authored-by: Andrey Cheptsov <andrey.cheptsov@github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d707629 commit 64bb005

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ uv.lock
2727

2828
profiling_results.html
2929
docs/docs/reference/api/rest/openapi.json
30+
docs/docs/reference/plugins/rest/rest_plugin_openapi.json

docs/docs/reference/api/rest/openapi.json

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/docs/gen_openapi_reference.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"""
44

55
import json
6-
7-
import mkdocs_gen_files
6+
from pathlib import Path
87

98
from dstack._internal.server.main import app
109
from dstack._internal.settings import DSTACK_VERSION
@@ -15,5 +14,8 @@
1514
{"url": "https://sky.dstack.ai", "description": "Managed server"},
1615
]
1716
app.version = DSTACK_VERSION or "0.0.0"
18-
with mkdocs_gen_files.open("docs/reference/api/rest/openapi.json", "w") as f:
19-
json.dump(app.openapi(), f)
17+
output_path = Path("docs/docs/reference/api/rest/openapi.json")
18+
output_path.parent.mkdir(parents=True, exist_ok=True)
19+
new_content = json.dumps(app.openapi())
20+
if not output_path.exists() or output_path.read_text() != new_content:
21+
output_path.write_text(new_content)

scripts/docs/gen_rest_plugin_spec_reference.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44

55
import json
66
import logging
7-
8-
import mkdocs_gen_files
7+
from pathlib import Path
98

109
from dstack._internal.settings import DSTACK_VERSION
1110

@@ -26,7 +25,8 @@
2625
{"url": "http://localhost:8000", "description": "Local server"},
2726
]
2827
app.version = DSTACK_VERSION or "0.0.0"
29-
with mkdocs_gen_files.open(
30-
"docs/reference/plugins/rest_plugin/rest_plugin_openapi.json", "w"
31-
) as f:
32-
json.dump(app.openapi(), f)
28+
output_path = Path("docs/docs/reference/plugins/rest/rest_plugin_openapi.json")
29+
output_path.parent.mkdir(parents=True, exist_ok=True)
30+
new_content = json.dumps(app.openapi())
31+
if not output_path.exists() or output_path.read_text() != new_content:
32+
output_path.write_text(new_content)

0 commit comments

Comments
 (0)