Skip to content

Commit 6110f8d

Browse files
committed
fix fastapi swagger, update fastapi static
1 parent 93598e9 commit 6110f8d

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

lite_bootstrap/bootstrappers/litestar_bootstrapper.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import dataclasses
2+
import pathlib
23
import typing
34

45
from lite_bootstrap import import_checker
@@ -174,9 +175,10 @@ def bootstrap(self) -> None:
174175
**self.bootstrap_config.swagger_extra_params,
175176
)
176177
if self.bootstrap_config.swagger_offline_docs:
178+
static_dir_path = pathlib.Path(__file__).parent.parent / "static/litestar_docs"
177179
self.bootstrap_config.application_config.route_handlers.append(
178180
create_static_files_router(
179-
path=self.bootstrap_config.swagger_static_path, directories=["lite_bootstrap/static/litestar_docs"]
181+
path=self.bootstrap_config.swagger_static_path, directories=[static_dir_path]
180182
)
181183
)
182184

lite_bootstrap/helpers/fastapi_helpers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import pathlib
12
import typing
23

34
from lite_bootstrap import import_checker
@@ -29,7 +30,8 @@ def enable_offline_docs(
2930
if typing.cast(Route, route).path not in (docs_url, redoc_url, swagger_ui_oauth2_redirect_url)
3031
]
3132

32-
app.mount(static_path, StaticFiles(directory="lite_bootstrap/static/fastapi_docs"), name="static")
33+
static_dir_path = pathlib.Path(__file__).parent.parent / "static/fastapi_docs"
34+
app.mount(static_path, StaticFiles(directory=static_dir_path), name="static")
3335

3436
@app.get(docs_url, include_in_schema=False)
3537
async def custom_swagger_ui_html(request: Request) -> HTMLResponse:

lite_bootstrap/static/fastapi_docs/swagger-ui-bundle.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lite_bootstrap/static/fastapi_docs/swagger-ui.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)