Skip to content

Commit 75b6e2e

Browse files
committed
chore: add swagger server
1 parent b54fc32 commit 75b6e2e

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

openagent/app.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from dotenv import load_dotenv
55
from fastapi import FastAPI, Request
66
from fastapi.middleware.cors import CORSMiddleware
7+
from fastapi.openapi.utils import get_openapi
78
from loguru import logger
89
from starlette.staticfiles import StaticFiles
910
import traceback
@@ -60,3 +61,28 @@ async def global_exception_handler(request: Request, exc: Exception):
6061
status_code=500,
6162
content={"error": str(exc), "traceback": traceback.format_exc()},
6263
)
64+
65+
66+
def custom_openapi():
67+
if app.openapi_schema:
68+
return app.openapi_schema
69+
70+
openapi_schema = get_openapi(
71+
title="OpenAgent API",
72+
version="1.0.0",
73+
description="OpenAgent API documentation",
74+
routes=app.routes,
75+
)
76+
77+
openapi_schema["servers"] = [
78+
{
79+
"url": "https://agent.open.network",
80+
"description": "Production server"
81+
}
82+
]
83+
84+
app.openapi_schema = openapi_schema
85+
return app.openapi_schema
86+
87+
88+
app.openapi = custom_openapi

0 commit comments

Comments
 (0)