Schema 代码片段

以 Markdown 格式查看

<SchemaSnippet> 组件将 API 参考中的类型定义显示为 JSON 代码块。您可以单独使用它来显示 JSON 表示,或将其与 <Schema> 组件配对使用,同时显示逐字段分解和 JSON。

该组件仅发现由端点引用的类型。专门由 websocket 或 webhook 使用的类型将不可用。如果多个 API 具有相同的类型名称,该组件会返回第一个匹配项。

用法

该组件与已在 docs.yml 中配置的 API 参考一起使用。此示例将 AIChatConfig 类型显示为 JSON 代码块:

AIChatConfig 对象
1{
2 "model": "claude-3.5",
3 "system-prompt": "string"
4}
Markdown
1<SchemaSnippet type="AIChatConfig" title="AIChatConfig 对象" />

与 Schema 组件结合使用

<SchemaSnippet><Schema> 一起使用,可同时显示 JSON 表示和详细的字段分解:

AIChatConfig 对象
1{
2 "model": "claude-3.5",
3 "system-prompt": "string"
4}
modelenumOptional
Allowed values:
system-promptstringOptional
This is a system prompt that acts as context given to the LLM for AI chat.
Markdown
1<SchemaSnippet type="AIChatConfig" title="AIChatConfig 对象" />
2
3<Schema type="AIChatConfig" />

属性

type
stringRequired

要显示的类型名称。该组件在您的 API 定义中的所有端点中搜索此类型。

title
string

显示在 JSON 代码块上方的可选标题。

className
string

用于自定义样式的可选 CSS 类名。

highlight
number | number[]

要在代码片段中高亮显示的行号。接受单个数字、数字数组或范围(例如,{[1-3, 5]})。