Skip to content

Commit

Permalink
chore: add swagger server
Browse files Browse the repository at this point in the history
  • Loading branch information
naaive committed Jan 3, 2025
1 parent b54fc32 commit 75b6e2e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions openagent/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from dotenv import load_dotenv
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi.openapi.utils import get_openapi
from loguru import logger
from starlette.staticfiles import StaticFiles
import traceback
Expand Down Expand Up @@ -60,3 +61,28 @@ async def global_exception_handler(request: Request, exc: Exception):
status_code=500,
content={"error": str(exc), "traceback": traceback.format_exc()},
)


def custom_openapi():
if app.openapi_schema:
return app.openapi_schema

openapi_schema = get_openapi(
title="OpenAgent API",
version="1.0.0",
description="OpenAgent API documentation",
routes=app.routes,
)

openapi_schema["servers"] = [
{
"url": "https://agent.open.network",
"description": "Production server"
}
]

app.openapi_schema = openapi_schema
return app.openapi_schema


app.openapi = custom_openapi

0 comments on commit 75b6e2e

Please sign in to comment.