mirror of
https://github.com/open-webui/open-webui
synced 2025-05-19 12:51:35 +00:00
feat: add support for OpenAPI spec in YAML format
This commit is contained in:
parent
66322727e3
commit
27e8c6fce4
@ -4,6 +4,7 @@ import re
|
|||||||
import inspect
|
import inspect
|
||||||
import aiohttp
|
import aiohttp
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import yaml
|
||||||
|
|
||||||
from typing import Any, Awaitable, Callable, get_type_hints, Dict, List, Union, Optional
|
from typing import Any, Awaitable, Callable, get_type_hints, Dict, List, Union, Optional
|
||||||
from functools import update_wrapper, partial
|
from functools import update_wrapper, partial
|
||||||
@ -398,6 +399,12 @@ async def get_tool_server_data(token: str, url: str) -> Dict[str, Any]:
|
|||||||
if response.status != 200:
|
if response.status != 200:
|
||||||
error_body = await response.json()
|
error_body = await response.json()
|
||||||
raise Exception(error_body)
|
raise Exception(error_body)
|
||||||
|
|
||||||
|
# Check if URL ends with .yaml or .yml to determine format
|
||||||
|
if url.lower().endswith((".yaml", ".yml")):
|
||||||
|
text_content = await response.text()
|
||||||
|
res = yaml.safe_load(text_content)
|
||||||
|
else:
|
||||||
res = await response.json()
|
res = await response.json()
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print("Error:", err)
|
print("Error:", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user