diff --git a/api/apps/__init__.py b/api/apps/__init__.py index c99e5f0dc..6e0f89c67 100644 --- a/api/apps/__init__.py +++ b/api/apps/__init__.py @@ -19,7 +19,6 @@ import sys from importlib.util import module_from_spec, spec_from_file_location from pathlib import Path from quart import Blueprint, Quart, request, g, current_app, session -from flasgger import Swagger from itsdangerous.url_safe import URLSafeTimedSerializer as Serializer from quart_cors import cors from common.constants import StatusEnum @@ -29,6 +28,7 @@ from api.utils.json_encode import CustomJSONEncoder from api.utils import commands from quart_auth import Unauthorized +from quart_schema import QuartSchema from common import settings from api.utils.api_utils import server_error_response from api.constants import API_VERSION @@ -41,37 +41,8 @@ __all__ = ["app"] app = Quart(__name__) app = cors(app, allow_origin="*") -# Add this at the beginning of your file to configure Swagger UI -swagger_config = { - "headers": [], - "specs": [ - { - "endpoint": "apispec", - "route": "/apispec.json", - "rule_filter": lambda rule: True, # Include all endpoints - "model_filter": lambda tag: True, # Include all models - } - ], - "static_url_path": "/flasgger_static", - "swagger_ui": True, - "specs_route": "/apidocs/", -} - -swagger = Swagger( - app, - config=swagger_config, - template={ - "swagger": "2.0", - "info": { - "title": "RAGFlow API", - "description": "", - "version": "1.0.0", - }, - "securityDefinitions": { - "ApiKeyAuth": {"type": "apiKey", "name": "Authorization", "in": "header"} - }, - }, -) +# openapi supported +QuartSchema(app) app.url_map.strict_slashes = False app.json_encoder = CustomJSONEncoder diff --git a/pyproject.toml b/pyproject.toml index 1db1ab84a..2575194eb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -152,6 +152,7 @@ dependencies = [ "pygithub>=2.8.1", "asana>=5.2.2", "python-gitlab>=7.0.0", + "quart-schema==0.23.0", ] [dependency-groups] diff --git a/uv.lock b/uv.lock index 426139c45..82ff34cec 100644 --- a/uv.lock +++ b/uv.lock @@ -5534,6 +5534,15 @@ wheels = [ { url = "https://pypi.tuna.tsinghua.edu.cn/packages/c7/21/705964c7812476f378728bdf590ca4b771ec72385c533964653c68e86bdc/pygments-2.19.2-py3-none-any.whl", hash = "sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b", size = 1225217, upload-time = "2025-06-21T13:39:07.939Z" }, ] +[[package]] +name = "pyhumps" +version = "3.8.0" +source = { registry = "https://pypi.tuna.tsinghua.edu.cn/simple" } +sdist = { url = "https://pypi.tuna.tsinghua.edu.cn/packages/c4/83/fa6f8fb7accb21f39e8f2b6a18f76f6d90626bdb0a5e5448e5cc9b8ab014/pyhumps-3.8.0.tar.gz", hash = "sha256:498026258f7ee1a8e447c2e28526c0bea9407f9a59c03260aee4bd6c04d681a3", size = 9018, upload-time = "2022-10-21T10:38:59.496Z" } +wheels = [ + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/9e/11/a1938340ecb32d71e47ad4914843775011e6e9da59ba1229f181fef3119e/pyhumps-3.8.0-py3-none-any.whl", hash = "sha256:060e1954d9069f428232a1adda165db0b9d8dfdce1d265d36df7fbff540acfd6", size = 6095, upload-time = "2022-10-21T10:38:58.231Z" }, +] + [[package]] name = "pyjwt" version = "2.8.0" @@ -6161,6 +6170,19 @@ wheels = [ { url = "https://pypi.tuna.tsinghua.edu.cn/packages/ea/31/da390a5a10674481dea2909178973de81fa3a246c0eedcc0e1e4114f52f8/quart_cors-0.8.0-py3-none-any.whl", hash = "sha256:62dc811768e2e1704d2b99d5880e3eb26fc776832305a19ea53db66f63837767", size = 8698, upload-time = "2024-12-27T20:34:29.511Z" }, ] +[[package]] +name = "quart-schema" +version = "0.23.0" +source = { registry = "https://pypi.tuna.tsinghua.edu.cn/simple" } +dependencies = [ + { name = "pyhumps" }, + { name = "quart" }, +] +sdist = { url = "https://pypi.tuna.tsinghua.edu.cn/packages/24/65/97b69c76bc8838f0389387c87f480382eea48ca60d5262aeaf4086ad14e2/quart_schema-0.23.0.tar.gz", hash = "sha256:778f36aa80697420a0148807eb324b7d6ca1f10793cd1d0eb4f1c7908d860bdd", size = 24485, upload-time = "2025-12-02T22:01:08.508Z" } +wheels = [ + { url = "https://pypi.tuna.tsinghua.edu.cn/packages/12/ba/54c4516499bf6549ff47d656b8dc8cd58cea7f6d03d3097aebf1958f4974/quart_schema-0.23.0-py3-none-any.whl", hash = "sha256:f8f217942d433954dfe9860b4d748fe4b111836d8d74e06bc0afc512dd991c80", size = 21682, upload-time = "2025-12-02T22:01:06.522Z" }, +] + [[package]] name = "ragflow" version = "0.23.1" @@ -6251,6 +6273,7 @@ dependencies = [ { name = "qianfan" }, { name = "quart-auth" }, { name = "quart-cors" }, + { name = "quart-schema" }, { name = "ranx" }, { name = "readability-lxml" }, { name = "replicate" }, @@ -6383,6 +6406,7 @@ requires-dist = [ { name = "qianfan", specifier = "==0.4.6" }, { name = "quart-auth", specifier = "==0.11.0" }, { name = "quart-cors", specifier = "==0.8.0" }, + { name = "quart-schema", specifier = "==0.23.0" }, { name = "ranx", specifier = "==0.3.20" }, { name = "readability-lxml", specifier = ">=0.8.4,<1.0.0" }, { name = "replicate", specifier = "==0.31.0" },