From 6584ceea7d42e6d80c44fa4897fc087a4c9629c4 Mon Sep 17 00:00:00 2001 From: sunhao Date: Thu, 18 Dec 2025 15:58:42 +0800 Subject: [PATCH 1/3] * [bug #68208] fix JSON formatting in API documentation by decoding HTML entities in params and response examples. --- module/zai/model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/zai/model.php b/module/zai/model.php index ff972ec5dc..8e4f058a02 100644 --- a/module/zai/model.php +++ b/module/zai/model.php @@ -1531,7 +1531,7 @@ class zaiModel extends model if(!empty($doc->paramsExample)) { $content[] = "\n## {$app->lang->api->paramsExample}\n"; - $content[] = "```json\n{$doc->paramsExample}\n```"; + $content[] = "```json\n" . htmlspecialchars_decode($doc->paramsExample) . "\n```"; } if(!empty($doc->response)) { @@ -1551,7 +1551,7 @@ class zaiModel extends model if(!empty($doc->responseExample)) { $content[] = "\n## {$app->lang->api->responseExample}\n"; - $content[] = "```json\n{$doc->responseExample}\n```"; + $content[] = "```json\n" . htmlspecialchars_decode($doc->responseExample) . "\n```"; } $content[] = "\n## {$app->lang->api->desc}\n"; From c2b874c001746c1c3938f42c2b4d248964f77b6a Mon Sep 17 00:00:00 2001 From: sunhao Date: Thu, 18 Dec 2025 16:42:42 +0800 Subject: [PATCH 2/3] * [misc] add docType to doc knowledge attrs. --- module/zai/model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/zai/model.php b/module/zai/model.php index 8e4f058a02..6f000c104e 100644 --- a/module/zai/model.php +++ b/module/zai/model.php @@ -1463,7 +1463,7 @@ class zaiModel extends model $app->loadLang('doc'); $lang = $app->lang; - if(isset($doc->protocol)) + if(isset($doc->protocol) || !empty($doc->api)) { $app->loadLang('api'); $markdown = array('id' => $doc->id, 'title' => "{$lang->doc->common} #$doc->id $doc->title"); @@ -1558,7 +1558,7 @@ class zaiModel extends model $content[] = strip_tags($doc->desc) . "\n"; $markdown['content'] = implode("\n", $content); - $markdown['attrs'] = array('product' => $doc->product, 'lib' => $doc->lib, 'module' => $doc->module, 'version' => $doc->version); + $markdown['attrs'] = array('product' => $doc->product, 'lib' => $doc->lib, 'module' => $doc->module, 'version' => $doc->version, 'docType' => 'api'); } else { From 80cb8db73dec72b00dd52bd468ce77f213f55c2d Mon Sep 17 00:00:00 2001 From: sunhao Date: Thu, 18 Dec 2025 16:59:00 +0800 Subject: [PATCH 3/3] * [misc] support for checking api in zai->canViewObject. --- module/zai/model.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/zai/model.php b/module/zai/model.php index 6f000c104e..a631f06018 100644 --- a/module/zai/model.php +++ b/module/zai/model.php @@ -656,7 +656,8 @@ class zaiModel extends model } elseif($objectType === 'doc') { - $doc = $this->loadModel('doc')->getByID($objectID); + $api = isset($attrs['docType']) && $attrs['docType'] === 'api'; + $doc = $this->loadModel($api ? 'api' : 'doc')->getByID($objectID); $canView = $this->loadModel('doc')->checkPrivDoc($doc); }