File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 44from dotenv import load_dotenv
55from fastapi import FastAPI , Request
66from fastapi .middleware .cors import CORSMiddleware
7+ from fastapi .openapi .utils import get_openapi
78from loguru import logger
89from starlette .staticfiles import StaticFiles
910import 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
You can’t perform that action at this time.
0 commit comments