mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
feat: add offline swagger docs (#7653)
This commit is contained in:
parent
f4c9dce211
commit
0ac896a6f2
4 changed files with 19 additions and 0 deletions
|
@ -348,10 +348,12 @@ from fastapi import (
|
|||
Response,
|
||||
UploadFile,
|
||||
status,
|
||||
applications
|
||||
)
|
||||
from fastapi.encoders import jsonable_encoder
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from fastapi.openapi.utils import get_openapi
|
||||
from fastapi.openapi.docs import get_swagger_ui_html
|
||||
from fastapi.responses import (
|
||||
FileResponse,
|
||||
JSONResponse,
|
||||
|
@ -749,6 +751,18 @@ app.add_middleware(
|
|||
|
||||
app.add_middleware(PrometheusAuthMiddleware)
|
||||
|
||||
swagger_path = os.path.join(current_dir, "swagger")
|
||||
app.mount("/swagger", StaticFiles(directory=swagger_path), name="swagger")
|
||||
def swagger_monkey_patch(*args, **kwargs):
|
||||
return get_swagger_ui_html(
|
||||
*args,
|
||||
**kwargs,
|
||||
swagger_js_url="/swagger/swagger-ui-bundle.js",
|
||||
swagger_css_url="/swagger/swagger-ui.css",
|
||||
swagger_favicon_url="/swagger/favicon.png"
|
||||
)
|
||||
applications.get_swagger_ui_html = swagger_monkey_patch
|
||||
|
||||
from typing import Dict
|
||||
|
||||
user_api_base = None
|
||||
|
|
BIN
litellm/proxy/swagger/favicon.png
Normal file
BIN
litellm/proxy/swagger/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
2
litellm/proxy/swagger/swagger-ui-bundle.js
Normal file
2
litellm/proxy/swagger/swagger-ui-bundle.js
Normal file
File diff suppressed because one or more lines are too long
3
litellm/proxy/swagger/swagger-ui.css
Normal file
3
litellm/proxy/swagger/swagger-ui.css
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue