Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/en/dev/openapi-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,14 @@ Manage plugins, plugin configuration, plugin sources, and marketplace data.
| `GET` | `/api/v1/plugins/page-bridge-sdk.js` | — |
| `GET` | `/api/v1/plugins/page/assets` | — |
| `GET` | `/api/v1/plugins/pages` | — |
| `GET` | `/api/v1/plugins/views` | — |
| `GET` | `/api/v1/plugins/view` | — |
| `GET` | `/api/v1/plugins/view/assets` | — |
| `GET` | `/api/v1/plugins/readme` | — |
| `POST` | `/api/v1/plugins/reload` | — |
| `POST` | `/api/v1/plugins/update` | — |
| `POST` | `/api/v1/plugins/validate/repo` | — |
| `POST` | `/api/v1/plugins/version-support/check` | — |
| `GET` | `/api/v1/plugins/view` | — |
| `GET` | `/api/v1/plugins/view/assets` | — |
| `GET` | `/api/v1/plugins/views` | — |
| `GET` | `/api/v1/plugins/{plugin_id}` | — |
| `DELETE` | `/api/v1/plugins/{plugin_id}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/changelog` | — |
Expand All @@ -278,13 +278,13 @@ Manage plugins, plugin configuration, plugin sources, and marketplace data.
| `GET` | `/api/v1/plugins/{plugin_id}/pages` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/pages/{page_name}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/pages/{page_name}/assets/{asset_path}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views/{page_name}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views/{page_name}/assets/{asset_path}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/readme` | — |
| `POST` | `/api/v1/plugins/{plugin_id}/reload` | — |
| `POST` | `/api/v1/plugins/{plugin_id}/source` | — |
| `POST` | `/api/v1/plugins/{plugin_id}/update` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views/{page_name}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views/{page_name}/assets/{asset_path}` | — |

## `mcp`

Expand Down
190 changes: 190 additions & 0 deletions docs/public/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4398,6 +4398,196 @@
"description": "**Required scope:** `plugin`"
}
},
"/api/v1/plugins/views": {
"get": {
"tags": [
"Plugin Pages"
],
"summary": "List plugin views by query ID (alias of /plugins/pages)",
"operationId": "listPluginViewsById",
"x-astrbot-scope": "plugin",
"parameters": [
{
"name": "plugin_id",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"$ref": "#/components/responses/Ok"
}
},
"description": "**Required scope:** `plugin`"
}
},
"/api/v1/plugins/view": {
"get": {
"tags": [
"Plugin Pages"
],
"summary": "Get plugin view entry HTML by query ID (alias of /plugins/page)",
"operationId": "getPluginViewById",
"x-astrbot-scope": "plugin",
"parameters": [
{
"name": "plugin_id",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "page_name",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"$ref": "#/components/responses/Html"
}
},
"description": "**Required scope:** `plugin`"
}
},
"/api/v1/plugins/view/assets": {
"get": {
"tags": [
"Plugin Pages"
],
"summary": "Get a plugin view asset by query ID (alias of /plugins/page/assets)",
"operationId": "getPluginViewAssetById",
"x-astrbot-scope": "plugin",
"parameters": [
{
"name": "plugin_id",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "page_name",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "asset_path",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Plugin asset content"
}
},
"description": "**Required scope:** `plugin`"
}
},
"/api/v1/plugins/{plugin_id}/views": {
"get": {
"tags": [
"Plugin Pages"
],
"summary": "List plugin views (alias of /plugins/{plugin_id}/pages)",
"operationId": "listPluginViews",
"x-astrbot-scope": "plugin",
"parameters": [
{
"$ref": "#/components/parameters/PluginId"
}
],
"responses": {
"200": {
"$ref": "#/components/responses/Ok"
}
},
"description": "**Required scope:** `plugin`"
}
},
"/api/v1/plugins/{plugin_id}/views/{page_name}": {
"get": {
"tags": [
"Plugin Pages"
],
"summary": "Get plugin view entry HTML (alias of /plugins/{plugin_id}/pages/{page_name})",
"operationId": "getPluginView",
"x-astrbot-scope": "plugin",
"parameters": [
{
"$ref": "#/components/parameters/PluginId"
},
{
"name": "page_name",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"$ref": "#/components/responses/Html"
}
},
"description": "**Required scope:** `plugin`"
}
},
"/api/v1/plugins/{plugin_id}/views/{page_name}/assets/{asset_path}": {
"get": {
"tags": [
"Plugin Pages"
],
"summary": "Get a plugin view asset (alias of /plugins/{plugin_id}/pages/{page_name}/assets/{asset_path})",
"operationId": "getPluginViewAsset",
"x-astrbot-scope": "plugin",
"parameters": [
{
"$ref": "#/components/parameters/PluginId"
},
{
"name": "page_name",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
{
"name": "asset_path",
"in": "path",
"required": true,
"description": "URL-encoded relative asset path.",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Plugin asset content"
}
},
"description": "**Required scope:** `plugin`"
}
},
"/api/v1/plugins/page-bridge-sdk.js": {
"get": {
"tags": [
Expand Down
12 changes: 6 additions & 6 deletions docs/zh/dev/openapi-scopes.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,14 @@ outline: deep
| `GET` | `/api/v1/plugins/page-bridge-sdk.js` | — |
| `GET` | `/api/v1/plugins/page/assets` | — |
| `GET` | `/api/v1/plugins/pages` | — |
| `GET` | `/api/v1/plugins/views` | — |
| `GET` | `/api/v1/plugins/view` | — |
| `GET` | `/api/v1/plugins/view/assets` | — |
| `GET` | `/api/v1/plugins/readme` | — |
| `POST` | `/api/v1/plugins/reload` | — |
| `POST` | `/api/v1/plugins/update` | — |
| `POST` | `/api/v1/plugins/validate/repo` | — |
| `POST` | `/api/v1/plugins/version-support/check` | — |
| `GET` | `/api/v1/plugins/view` | — |
| `GET` | `/api/v1/plugins/view/assets` | — |
| `GET` | `/api/v1/plugins/views` | — |
| `GET` | `/api/v1/plugins/{plugin_id}` | — |
| `DELETE` | `/api/v1/plugins/{plugin_id}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/changelog` | — |
Expand All @@ -278,13 +278,13 @@ outline: deep
| `GET` | `/api/v1/plugins/{plugin_id}/pages` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/pages/{page_name}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/pages/{page_name}/assets/{asset_path}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views/{page_name}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views/{page_name}/assets/{asset_path}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/readme` | — |
| `POST` | `/api/v1/plugins/{plugin_id}/reload` | — |
| `POST` | `/api/v1/plugins/{plugin_id}/source` | — |
| `POST` | `/api/v1/plugins/{plugin_id}/update` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views/{page_name}` | — |
| `GET` | `/api/v1/plugins/{plugin_id}/views/{page_name}/assets/{asset_path}` | — |

## `mcp`

Expand Down
2 changes: 1 addition & 1 deletion tests/test_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2058,7 +2058,7 @@ async def test_plugin_page_content_issues_scoped_asset_token(
bridge_response = await anonymous_client.get(bridge_sdk_url.group(1))
assert bridge_response.status_code == 200
bridge_js = (await bridge_response.get_data()).decode("utf-8")
assert "window.AstrBotPluginPage?.__setInitialContext" in bridge_js
assert "window.AstrBotPluginView?.__setInitialContext" in bridge_js
assert '"locale": "zh-CN"' in bridge_js
assert '"displayName": "插件页面演示"' in bridge_js
assert '"pageTitle": "Bridge 演示页"' in bridge_js
Expand Down
21 changes: 18 additions & 3 deletions tests/test_plugin_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,26 @@ def test_load_plugin_metadata_includes_i18n(tmp_path: Path):

assert metadata is not None
assert metadata.short_desc == "Local test short description"
assert metadata.pages == []
assert metadata.views == []
assert metadata.i18n == {"zh-CN": {"metadata": {"display_name": "你好世界"}}}


def test_load_plugin_metadata_includes_pages(tmp_path: Path):
def test_load_plugin_metadata_includes_views(tmp_path: Path):
plugin_path = tmp_path / "helloworld"
_write_local_test_plugin(plugin_path, TEST_PLUGIN_REPO)
metadata_path = plugin_path / "metadata.yaml"
metadata = yaml.safe_load(metadata_path.read_text(encoding="utf-8"))
metadata["views"] = [{"name": "dashboard", "title": "Dashboard"}]
metadata_path.write_text(yaml.dump(metadata), encoding="utf-8")

loaded_metadata = PluginManager._load_plugin_metadata(str(plugin_path))

assert loaded_metadata is not None
assert loaded_metadata.views == [{"name": "dashboard", "title": "Dashboard"}]


def test_load_plugin_metadata_pages_alias_maps_to_views(tmp_path: Path):
# "pages" stays a compatible alias for "views" in metadata.yaml.
plugin_path = tmp_path / "helloworld"
_write_local_test_plugin(plugin_path, TEST_PLUGIN_REPO)
metadata_path = plugin_path / "metadata.yaml"
Expand All @@ -156,7 +171,7 @@ def test_load_plugin_metadata_includes_pages(tmp_path: Path):
loaded_metadata = PluginManager._load_plugin_metadata(str(plugin_path))

assert loaded_metadata is not None
assert loaded_metadata.pages == [{"name": "dashboard", "title": "Dashboard"}]
assert loaded_metadata.views == [{"name": "dashboard", "title": "Dashboard"}]


def test_load_plugin_metadata_accepts_yml_suffix(tmp_path: Path):
Expand Down
Loading