From 4648cb9e87e83e42ecc52406700255a23e11072a Mon Sep 17 00:00:00 2001 From: invictus Date: Tue, 7 Apr 2026 00:14:24 +0800 Subject: [PATCH] docs: use model_dump(by_alias=True) for default_config in plugin guide --- docs/CHANNEL_PLUGIN_GUIDE.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/CHANNEL_PLUGIN_GUIDE.md b/docs/CHANNEL_PLUGIN_GUIDE.md index f3f472d3f..d34e13848 100644 --- a/docs/CHANNEL_PLUGIN_GUIDE.md +++ b/docs/CHANNEL_PLUGIN_GUIDE.md @@ -69,7 +69,7 @@ class WebhookChannel(BaseChannel): @classmethod def default_config(cls) -> dict[str, Any]: - return {"enabled": False, "port": 9000, "allowFrom": []} + return WebhookConfig().model_dump(by_alias=True) async def start(self) -> None: """Start an HTTP server that listens for incoming messages. @@ -401,10 +401,10 @@ Override `default_config()` so `nanobot onboard` auto-populates `config.json`: ```python @classmethod def default_config(cls) -> dict[str, Any]: - return {"enabled": False, "port": 9000, "allowFrom": []} + return WebhookConfig().model_dump(by_alias=True) ``` -> **Note:** `default_config()` still returns a plain `dict` (not a Pydantic model) because it's used to serialize into `config.json`. Use camelCase keys (`allowFrom`) to match the JSON convention. +> **Note:** `default_config()` returns a plain `dict` (not a Pydantic model) because it's used to serialize into `config.json`. The recommended way is to instantiate your config model and call `model_dump(by_alias=True)` — this automatically uses camelCase keys (`allowFrom`) and keeps defaults in a single source of truth. If not overridden, the base class returns `{"enabled": false}`.