Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

♻️ Migrate outline API contracts https://github.com/siyuan-note/siyuan/issues/19378

Daniel2e35691d181b
diff --git a/app/src/editor/util.ts b/app/src/editor/util.ts
index e2b23b857a..7ae16c4c68 100644
--- a/app/src/editor/util.ts
+++ b/app/src/editor/util.ts
@@ -754,7 +754,7 @@ export const updateOutline = (models: IModels, protyle: IProtyle, reload = false
item.isPreview = !protyle.preview.element.classList.contains("fn__none");
item.update(response, blockId, protyle?.notebookId || "");
if (protyle) {
- item.updateDocTitle(protyle.background.ial, response.data?.length || 0);
+ item.updateDocTitle(protyle.background.ial, Array.isArray(response.data) ? response.data.length : 0);
if (getSelection().rangeCount > 0) {
const startContainer = getSelection().getRangeAt(0).startContainer;
if (protyle.wysiwyg.element.contains(startContainer)) {
diff --git a/app/src/layout/dock/Outline.ts b/app/src/layout/dock/Outline.ts
index 66490de9a2..b8b5b7544e 100644
--- a/app/src/layout/dock/Outline.ts
+++ b/app/src/layout/dock/Outline.ts
@@ -313,7 +313,7 @@ export class Outline extends Model {
}
this.update(response);
if (this.blockId) {
- this.updateDocTitle((options.tab.model as Editor)?.editor?.protyle?.background?.ial, response.data?.length || 0);
+ this.updateDocTitle((options.tab.model as Editor)?.editor?.protyle?.background?.ial, Array.isArray(response.data) ? response.data.length : 0);
}
});
}
@@ -580,7 +580,7 @@ export class Outline extends Model {
return;
}
this.update(response);
- this.updateDocTitle(null, response.data?.length || 0);
+ this.updateDocTitle(null, Array.isArray(response.data) ? response.data.length : 0);
// https://github.com/siyuan-note/siyuan/issues/8372
if (getSelection().rangeCount > 0) {
const blockElement = hasClosestBlock(getSelection().getRangeAt(0).startContainer);
@@ -769,7 +769,7 @@ export class Outline extends Model {
return;
}
this.update(response);
- this.updateDocTitle(protyle?.background?.ial, response.data?.length || 0);
+ this.updateDocTitle(protyle?.background?.ial, Array.isArray(response.data) ? response.data.length : 0);
});
}
diff --git a/app/src/mobile/dock/MobileOutline.ts b/app/src/mobile/dock/MobileOutline.ts
index b9517cc259..d54bca2072 100644
--- a/app/src/mobile/dock/MobileOutline.ts
+++ b/app/src/mobile/dock/MobileOutline.ts
@@ -578,7 +578,7 @@ export class MobileOutline extends Model {
return;
}
this.update(response);
- this.updateDocTitle(protyle?.background?.ial, response.data?.length || 0);
+ this.updateDocTitle(protyle?.background?.ial, Array.isArray(response.data) ? response.data.length : 0);
callback?.();
});
}
diff --git a/app/src/types/api/index.d.ts b/app/src/types/api/index.d.ts
index fcfa898815..2dc4bb4690 100644
--- a/app/src/types/api/index.d.ts
+++ b/app/src/types/api/index.d.ts
@@ -160,6 +160,8 @@ export type HeadingFoldRequestInput = { "id": string; "scope": string; };
export type HeadingLevelRequestInput = { "id"?: string; "ids"?: Array<string>; "level": number; };
+export type HeadingNumbersRequestInput = { "id"?: string | null; "notebook"?: string | null; };
+
export type ImportNotebookCryptoBackupRequestInput = { "file": Blob; "password"?: string; };
export type InlineStyle = { "dark": InlineStyleTheme | null; "hidden"?: boolean; "id": string; "light": InlineStyleTheme | null; "name": string; };
@@ -252,6 +254,8 @@ export type OpenNotebookRequestInput = { "app"?: string | null; "notebook": stri
export type OrderedListStartData = { "found": boolean; "start": number; };
+export type OutlineRequestInput = { "id"?: string | null; "notebook"?: string | null; "preview"?: boolean | null; };
+
export type OutlineStorageRequestInput = { "docID": string; };
export type OutlineStorageSetRequestInput = { "docID": string; "val": { [key: string]: JSONValue }; };
@@ -304,6 +308,8 @@ export type SearchHistoryData = { "histories": Array<string> | null; "pageCount"
export type SearchHistoryRequestInput = { "notebook"?: string | null; "op"?: string | null; "page"?: number | null; "query"?: string | null; "type"?: number | null; };
+export type SearchPath = { "blocks"?: Array<SearchBlock | null>; "box": string; "children"?: Array<SearchPath | null>; "count": number; "created": string; "depth": number; "folded": boolean; "hPath": string; "id": string; "name": string; "nodeType": string; "number"?: string; "subType": string; "type": string; "updated": string; };
+
export type SearchSubTypes = { "heading": Record<string, boolean> | null; "list": Record<string, boolean> | null; "listItem": Record<string, boolean> | null; };
export type SearchSubTypesInput = { "heading"?: Record<string, boolean> | null; "list"?: Record<string, boolean> | null; "listItem"?: Record<string, boolean> | null; };
@@ -689,8 +695,6 @@ export type APILegacyPOSTPath =
"/api/network/echo/*path" |
"/api/network/forwardProxy" |
"/api/network/proxy" |
- "/api/outline/getDocHeadingNumbers" |
- "/api/outline/getDocOutline" |
"/api/petal/loadPetals" |
"/api/petal/setPetalEnabled" |
"/api/petal/setPetalPublishEnabled" |
@@ -1401,6 +1405,16 @@ export interface APIPOSTRoutes {
response: { "code": 0; "data": NotificationData; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
body: "json";
};
+ "/api/outline/getDocHeadingNumbers": {
+ request: HeadingNumbersRequestInput;
+ response: { "code": 0; "data": Record<string, string> | null; "msg": string; } | { "code": -1 | 1; "data": { "closeTimeout": number; } | null; "msg": string; };
+ body: "json";
+ };
+ "/api/outline/getDocOutline": {
+ request: OutlineRequestInput;
+ response: { "code": 0; "data": Array<SearchPath | null> | null; "msg": string; } | { "code": -1 | 1; "data": { "closeTimeout": number; } | null; "msg": string; };
+ body: "json";
+ };
"/api/repo/checkSnapshot": {
request: EmptyRequestInput;
response: { "code": 0; "data": CheckSnapshotData; "msg": string; } | { "code": -1; "data": { "closeTimeout": number; } | null; "msg": string; };
diff --git a/kernel/api/contract_outline_test.go b/kernel/api/contract_outline_test.go
new file mode 100644
index 0000000000..fb49ef26e3
--- /dev/null
+++ b/kernel/api/contract_outline_test.go
@@ -0,0 +1,25 @@
+package api
+
+import (
+ "net/http/httptest"
+ "strings"
+ "testing"
+
+ "github.com/gin-gonic/gin"
+)
+
+func TestAPIContractOutlineEmptyInputs(t *testing.T) {
+ engine := gin.New()
+ engine.POST("/api/outline/getDocOutline", getDocOutline)
+ engine.POST("/api/outline/getDocHeadingNumbers", getDocHeadingNumbers)
+ for _, path := range []string{"/api/outline/getDocOutline", "/api/outline/getDocHeadingNumbers"} {
+ for _, body := range []string{`{}`, `{"id":null,"preview":42,"notebook":42}`} {
+ recorder := httptest.NewRecorder()
+ engine.ServeHTTP(recorder, httptest.NewRequest("POST", path, strings.NewReader(body)))
+ requireAPIContract(t, "POST", path, recorder)
+ if !strings.Contains(recorder.Body.String(), `"code":0`) {
+ t.Fatalf("missing ID must retain empty success: %s %s: %s", path, body, recorder.Body.String())
+ }
+ }
+ }
+}
diff --git a/kernel/api/contract_search_block.go b/kernel/api/contract_search_block.go
index 9bf650a118..2ae665ea21 100644
--- a/kernel/api/contract_search_block.go
+++ b/kernel/api/contract_search_block.go
@@ -34,3 +34,16 @@ func searchBlockContracts(blocks []*model.Block) []*apicontract.SearchBlock {
}
return result
}
+
+func searchPathContracts(values []*model.Path) []*apicontract.SearchPath {
+ if values == nil {
+ return nil
+ }
+ result := make([]*apicontract.SearchPath, len(values))
+ for i, value := range values {
+ if value != nil {
+ result[i] = &apicontract.SearchPath{ID: value.ID, Box: value.Box, Name: value.Name, Number: value.Number, HPath: value.HPath, Type: value.Type, NodeType: value.NodeType, SubType: value.SubType, Blocks: searchBlockContracts(value.Blocks), Children: searchPathContracts(value.Children), Depth: value.Depth, Count: value.Count, Folded: value.Folded, Updated: value.Updated, Created: value.Created}
+ }
+ }
+ return result
+}
diff --git a/kernel/api/outline.go b/kernel/api/outline.go
index 34302b3944..2f0cc028d5 100644
--- a/kernel/api/outline.go
+++ b/kernel/api/outline.go
@@ -17,7 +17,7 @@
package api
import (
- "net/http"
+ "github.com/siyuan-note/siyuan/kernel/apicontract"
"github.com/88250/gulu"
"github.com/gin-gonic/gin"
@@ -26,38 +26,25 @@ import (
"github.com/siyuan-note/siyuan/kernel/util"
)
-func getDocOutline(c *gin.Context) {
+var getDocOutline = contractHandler(apicontract.GetDocOutline, func(c *gin.Context, request apicontract.OutlineRequest) apicontract.Response[[]*apicontract.SearchPath] {
ret := gulu.Ret.NewResult()
- defer c.JSON(http.StatusOK, ret)
- arg, ok := util.JsonArg(c, ret)
- if !ok {
- return
+ if request.ID == nil {
+ return apicontract.Success[[]*apicontract.SearchPath](nil)
}
-
- if nil == arg["id"] {
- return
- }
-
- preview := false
- if previewArg := arg["preview"]; nil != previewArg {
- preview = previewArg.(bool)
- }
-
- rootID := arg["id"].(string)
+ rootID, preview := *request.ID, request.Preview
if util.InvalidIDPattern(rootID, ret) {
- return
+ return contractFailure[[]*apicontract.SearchPath](ret)
}
- notebook, _ := arg["notebook"].(string)
+ notebook := request.Notebook
if isEncryptedNotebookDeniedForPublish(c, notebook) {
- ret.Data = []*model.Path{}
- return
+ return apicontract.Success([]*apicontract.SearchPath{})
}
if err := holdEncryptedBoxRequest(c, notebook); err != nil {
ret.Code = 1
ret.Msg = err.Error()
- return
+ return contractFailure[[]*apicontract.SearchPath](ret)
}
var headings []*model.Path
var err error
@@ -69,7 +56,7 @@ func getDocOutline(c *gin.Context) {
if err != nil {
ret.Code = 1
ret.Msg = err.Error()
- return
+ return contractFailure[[]*apicontract.SearchPath](ret)
}
if model.IsReadOnlyRoleContext(c) {
publishAccess := model.GetPublishAccess()
@@ -85,32 +72,27 @@ func getDocOutline(c *gin.Context) {
}
}
}
- ret.Data = headings
-}
+ return apicontract.Success(searchPathContracts(headings))
+})
-func getDocHeadingNumbers(c *gin.Context) {
+var getDocHeadingNumbers = contractHandler(apicontract.GetDocHeadingNumbers, func(c *gin.Context, request apicontract.HeadingNumbersRequest) apicontract.Response[map[string]string] {
ret := gulu.Ret.NewResult()
- defer c.JSON(http.StatusOK, ret)
- arg, ok := util.JsonArg(c, ret)
- if !ok {
- return
+ if request.ID == nil {
+ return apicontract.Success[map[string]string](nil)
}
-
- rootID, ok := arg["id"].(string)
- if !ok || util.InvalidIDPattern(rootID, ret) {
- return
+ rootID := *request.ID
+ if util.InvalidIDPattern(rootID, ret) {
+ return contractFailure[map[string]string](ret)
}
-
- notebook, _ := arg["notebook"].(string)
+ notebook := request.Notebook
if isEncryptedNotebookDeniedForPublish(c, notebook) {
- ret.Data = map[string]string{}
- return
+ return apicontract.Success(map[string]string{})
}
if err := holdEncryptedBoxRequest(c, notebook); err != nil {
ret.Code = 1
ret.Msg = err.Error()
- return
+ return contractFailure[map[string]string](ret)
}
numbers := map[string]string{}
var err error
@@ -122,7 +104,7 @@ func getDocHeadingNumbers(c *gin.Context) {
if nil != err {
ret.Code = 1
ret.Msg = err.Error()
- return
+ return contractFailure[map[string]string](ret)
}
if model.IsReadOnlyRoleContext(c) {
publishAccess := model.GetPublishAccess()
@@ -141,5 +123,5 @@ func getDocHeadingNumbers(c *gin.Context) {
}
}
- ret.Data = numbers
-}
+ return apicontract.Success(numbers)
+})
diff --git a/kernel/apicontract/contracts.go b/kernel/apicontract/contracts.go
index 609b5ae287..6ea046d2aa 100644
--- a/kernel/apicontract/contracts.go
+++ b/kernel/apicontract/contracts.go
@@ -410,3 +410,6 @@ var BatchUpdateRecentDocCloseTime = define[RecentDocsUpdateRequest, Null]("batch
var GetInlineStyles = define[EmptyRequest, *InlineStyles]("getInlineStyles", "/api/storage/getInlineStyles", NoBody, ResponseOptions{}, "POST")
var SetInlineStyles = define[SetInlineStylesRequest, *InlineStyles]("setInlineStyles", "/api/storage/setInlineStyles", JSONBody, ResponseOptions{}, "POST")
var SetWorkspaceAVPalette = define[WorkspaceAVPaletteRequest, *InlineStyles]("setWorkspaceAVPalette", "/api/storage/setWorkspaceAVPalette", JSONBody, ResponseOptions{}, "POST")
+
+var GetDocOutline = define[OutlineRequest, []*SearchPath]("getDocOutline", "/api/outline/getDocOutline", JSONBody, ResponseOptions{AdditionalCodes: []int{1}}, "POST")
+var GetDocHeadingNumbers = define[HeadingNumbersRequest, map[string]string]("getDocHeadingNumbers", "/api/outline/getDocHeadingNumbers", JSONBody, ResponseOptions{AdditionalCodes: []int{1}}, "POST")
diff --git a/kernel/apicontract/legacy_routes.json b/kernel/apicontract/legacy_routes.json
index 8ce91ec0f3..7add997ae4 100644
--- a/kernel/apicontract/legacy_routes.json
+++ b/kernel/apicontract/legacy_routes.json
@@ -283,8 +283,6 @@
{"method":"POST","path":"/api/lute/spinBlockDOM","handler":"spinBlockDOM"},
{"method":"POST","path":"/api/lute/wpsPresentation2BlockDOM","handler":"wpsPresentation2BlockDOM"},
{"method":"POST","path":"/api/network/forwardProxy","handler":"forwardProxy"},
- {"method":"POST","path":"/api/outline/getDocHeadingNumbers","handler":"getDocHeadingNumbers"},
- {"method":"POST","path":"/api/outline/getDocOutline","handler":"getDocOutline"},
{"method":"POST","path":"/api/petal/loadPetals","handler":"loadPetals"},
{"method":"POST","path":"/api/petal/setPetalEnabled","handler":"setPetalEnabled"},
{"method":"POST","path":"/api/petal/setPetalPublishEnabled","handler":"setPetalPublishEnabled"},
diff --git a/kernel/apicontract/outline.go b/kernel/apicontract/outline.go
new file mode 100644
index 0000000000..b421d5ab13
--- /dev/null
+++ b/kernel/apicontract/outline.go
@@ -0,0 +1,67 @@
+package apicontract
+
+import (
+ "bytes"
+ "encoding/json"
+ "io"
+)
+
+type OutlineRequest struct {
+ ID *string `json:"id" api:"optional"`
+ Preview bool `json:"preview" api:"optional,nullable"`
+ Notebook string `json:"notebook" api:"optional,nullable,ignoretype"`
+}
+
+type HeadingNumbersRequest struct {
+ ID *string `json:"id" api:"optional"`
+ Notebook string `json:"notebook" api:"optional,nullable,ignoretype"`
+}
+
+type SearchPath struct {
+ ID string `json:"id"`
+ Box string `json:"box"`
+ Name string `json:"name"`
+ Number string `json:"number,omitempty"`
+ HPath string `json:"hPath"`
+ Type string `json:"type"`
+ NodeType string `json:"nodeType"`
+ SubType string `json:"subType"`
+ Blocks []*SearchBlock `json:"blocks,omitempty"`
+ Children []*SearchPath `json:"children,omitempty"`
+ Depth int `json:"depth"`
+ Count int `json:"count"`
+ Folded bool `json:"folded"`
+ Updated string `json:"updated"`
+ Created string `json:"created"`
+}
+
+func init() {
+ plain := GetDocOutline
+ GetDocOutline.decodeRequest = func(reader io.Reader) (request OutlineRequest, err error) {
+ fields, err := blockRequestFields(reader, "/api/outline/getDocOutline")
+ if err != nil {
+ return request, err
+ }
+ if raw := fields["id"]; len(raw) == 0 || bytes.Equal(raw, []byte("null")) {
+ return request, nil
+ }
+ data, err := json.Marshal(fields)
+ if err != nil {
+ return request, err
+ }
+ return plain.Decode(bytes.NewReader(data))
+ }
+ GetDocHeadingNumbers.decodeRequest = func(reader io.Reader) (request HeadingNumbersRequest, err error) {
+ fields, err := blockRequestFields(reader, "/api/outline/getDocHeadingNumbers")
+ if err != nil {
+ return request, err
+ }
+ var id string
+ if raw := fields["id"]; len(raw) == 0 || bytes.Equal(raw, []byte("null")) || json.Unmarshal(raw, &id) != nil {
+ return request, nil
+ }
+ request.ID = &id
+ _ = json.Unmarshal(fields["notebook"], &request.Notebook)
+ return
+ }
+}
diff --git a/kernel/apicontract/outline_test.go b/kernel/apicontract/outline_test.go
new file mode 100644
index 0000000000..d42fd9d28a
--- /dev/null
+++ b/kernel/apicontract/outline_test.go
@@ -0,0 +1,22 @@
+package apicontract
+
+import (
+ "strings"
+ "testing"
+)
+
+func TestOutlineRequestCompatibility(t *testing.T) {
+ for _, body := range []string{`{}`, `{"id":null}`, `{"id":42}`, `{"id":{}}`, `{"id":[]}`} {
+ request, err := GetDocHeadingNumbers.Decode(strings.NewReader(body))
+ if err != nil || request.ID != nil {
+ t.Fatalf("heading numbers must ignore non-string ID: %s: %#v, %v", body, request, err)
+ }
+ }
+ request, err := GetDocOutline.Decode(strings.NewReader(`{"id":" id ","preview":null,"notebook":42}`))
+ if err != nil || request.ID == nil || *request.ID != " id " || request.Preview || request.Notebook != "" {
+ t.Fatalf("outline request changed: %#v, %v", request, err)
+ }
+ if _, err = GetDocOutline.Decode(strings.NewReader(`{"id":"id","preview":42}`)); err == nil {
+ t.Fatal("outline accepted invalid preview")
+ }
+}
diff --git a/kernel/apicontract/schema.json b/kernel/apicontract/schema.json
index de15060088..05c1be4c11 100644
--- a/kernel/apicontract/schema.json
+++ b/kernel/apicontract/schema.json
@@ -2964,6 +2964,32 @@
],
"additionalProperties": false
},
+ "HeadingNumbersRequestInput": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "notebook": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
"ImportNotebookCryptoBackupRequestInput": {
"type": "object",
"properties": {
@@ -4629,6 +4655,42 @@
],
"additionalProperties": false
},
+ "OutlineRequestInput": {
+ "type": "object",
+ "properties": {
+ "id": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "notebook": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "preview": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "additionalProperties": false
+ },
"OutlineStorageRequestInput": {
"type": "object",
"properties": {
@@ -5418,6 +5480,91 @@
},
"additionalProperties": false
},
+ "SearchPath": {
+ "type": "object",
+ "properties": {
+ "blocks": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SearchBlock"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "box": {
+ "type": "string"
+ },
+ "children": {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SearchPath"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ "count": {
+ "type": "integer"
+ },
+ "created": {
+ "type": "string"
+ },
+ "depth": {
+ "type": "integer"
+ },
+ "folded": {
+ "type": "boolean"
+ },
+ "hPath": {
+ "type": "string"
+ },
+ "id": {
+ "type": "string"
+ },
+ "name": {
+ "type": "string"
+ },
+ "nodeType": {
+ "type": "string"
+ },
+ "number": {
+ "type": "string"
+ },
+ "subType": {
+ "type": "string"
+ },
+ "type": {
+ "type": "string"
+ },
+ "updated": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "box",
+ "count",
+ "created",
+ "depth",
+ "folded",
+ "hPath",
+ "id",
+ "name",
+ "nodeType",
+ "subType",
+ "type",
+ "updated"
+ ],
+ "additionalProperties": false
+ },
"SearchSubTypes": {
"type": "object",
"properties": {
@@ -15337,6 +15484,185 @@
]
}
},
+ {
+ "method": "POST",
+ "path": "/api/outline/getDocHeadingNumbers",
+ "handler": "getDocHeadingNumbers",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/HeadingNumbersRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "additionalProperties": {
+ "type": "string"
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1,
+ 1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
+ {
+ "method": "POST",
+ "path": "/api/outline/getDocOutline",
+ "handler": "getDocOutline",
+ "body": "json",
+ "request": {
+ "$ref": "#/$defs/OutlineRequestInput"
+ },
+ "response": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ 0
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "array",
+ "items": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/SearchPath"
+ },
+ {
+ "type": "null"
+ }
+ ]
+ }
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "object",
+ "properties": {
+ "code": {
+ "type": "integer",
+ "enum": [
+ -1,
+ 1
+ ]
+ },
+ "data": {
+ "anyOf": [
+ {
+ "type": "object",
+ "properties": {
+ "closeTimeout": {
+ "type": "number"
+ }
+ },
+ "required": [
+ "closeTimeout"
+ ],
+ "additionalProperties": false
+ },
+ {
+ "type": "null"
+ }
+ ]
+ },
+ "msg": {
+ "type": "string"
+ }
+ },
+ "required": [
+ "code",
+ "msg",
+ "data"
+ ],
+ "additionalProperties": true
+ }
+ ]
+ }
+ },
{
"method": "POST",
"path": "/api/repo/checkSnapshot",