From 096f0d72f10a731f65a8c942c1f769d9f5e0957d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=8E=E8=A7=81?= <66513481+A-kirami@users.noreply.github.com> Date: Sat, 8 Jan 2022 22:19:45 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BB=8E=20Fastapi=20=E7=9A=84=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E4=B8=AD=E6=8E=92=E9=99=A4=E9=A9=B1=E5=8A=A8=E5=99=A8?= =?UTF-8?q?=E7=9A=84=20HTTP=20=E4=B8=8A=E6=8A=A5=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot/drivers/fastapi.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nonebot/drivers/fastapi.py b/nonebot/drivers/fastapi.py index 59f82563..54e0c2bc 100644 --- a/nonebot/drivers/fastapi.py +++ b/nonebot/drivers/fastapi.py @@ -179,6 +179,7 @@ class Driver(ReverseDriver): _handle, name=setup.name, methods=[setup.method], + include_in_schema=False, ) @overrides(ReverseDriver) From d82f0c63101c98be3fb736c16131f12c1cb2ee0c Mon Sep 17 00:00:00 2001 From: yanyongyu Date: Tue, 11 Jan 2022 15:03:17 +0800 Subject: [PATCH 2/2] :alembic: add config option for fastapi --- nonebot/drivers/fastapi.py | 12 +++++++++++- website/docs/tutorial/choose-driver.md | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/nonebot/drivers/fastapi.py b/nonebot/drivers/fastapi.py index 54e0c2bc..882e97b0 100644 --- a/nonebot/drivers/fastapi.py +++ b/nonebot/drivers/fastapi.py @@ -76,6 +76,16 @@ class Config(BaseSettings): ``redoc`` 地址,默认为 ``None`` 即关闭 """ + fastapi_include_adapter_schema: bool = True + """ + :类型: + + ``bool`` + + :说明: + + 是否包含适配器路由的 schema,默认为 ``True`` + """ fastapi_reload: bool = False """ :类型: @@ -179,7 +189,7 @@ class Driver(ReverseDriver): _handle, name=setup.name, methods=[setup.method], - include_in_schema=False, + include_in_schema=self.fastapi_config.fastapi_include_adapter_schema, ) @overrides(ReverseDriver) diff --git a/website/docs/tutorial/choose-driver.md b/website/docs/tutorial/choose-driver.md index b157b128..454f994f 100644 --- a/website/docs/tutorial/choose-driver.md +++ b/website/docs/tutorial/choose-driver.md @@ -82,6 +82,12 @@ DRIVER=~fastapi 默认值: `None` 说明: `FastAPI` 提供的 `ReDoc` 文档地址,如果为 `None`,则不提供 `ReDoc` 文档。 +##### `fastapi_include_adapter_schema` + +类型: `bool` +默认值: `True` +说明: `FastAPI` 提供的 `OpenAPI` JSON 定义中是否包含适配器路由的 `Schema`。 + ##### `fastapi_reload` 类型: `bool`