Files
locadex-agent[bot] bbb1a08ed3 docs(locadex): update translations (#1778)
Co-authored-by: locadex-agent[bot] <217277504+locadex-agent[bot]@users.noreply.github.com>
2025-11-14 14:44:09 -08:00

108 lines
2.6 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "字段"
description: "使用类型信息为 API 请求和响应的参数编写文档。"
keywords: ["ParamField", "ResponseField", "request parameters", "response documentation"]
---
使用字段为 API 的参数与响应编写文档。字段分为两类:参数字段和响应字段。
<div id="parameter-field">
## 参数字段
</div>
`<ParamField>` 组件用于为你的 API 或 SDK 定义参数。添加一个 `ParamField` 将自动添加一个 [API 操作台](/zh/api-playground/overview)。
<ParamField path="param" type="string" required>
参数字段示例
</ParamField>
```mdx
<ParamField path="param" type="string" required>
参数字段示例
</ParamField>
```
<div id="properties">
### 属性
</div>
<ParamField body="query, path, body, or header" type="string">
指定参数属于 query、path、body 或 header,后面跟随
参数名称。
</ParamField>
<ParamField body="type" type="string">
参数值的预期类型。
支持 `number`、`string`、`boolean`、`object`。
可使用 `[]` 后缀定义数组,例如 `string[]`。
</ParamField>
<ParamField body="required" type="boolean">
指明该参数是否为必填。
</ParamField>
<ParamField body="deprecated" type="boolean">
指明该参数是否已废弃。
</ParamField>
<ParamField body="default" type="any">
当请求的值为空时将使用的默认值。
</ParamField>
<ParamField body="placeholder" type="string">
playground 中输入框的占位文本。
</ParamField>
<ParamField body="children" type="string">
参数说明(支持 Markdown)。
</ParamField>
<div id="response-field">
## 响应字段
</div>
`<ResponseField>` 组件用于定义 API 的返回值。
<ResponseField name="response" type="string" required>
响应字段示例
</ResponseField>
```mdx
<ResponseField name="response" type="string" required>
响应字段示例
</ResponseField>
```
<div id="properties">
### 属性
</div>
<ResponseField name="name" type="string" required>
响应值的名称。
</ResponseField>
<ResponseField name="type" type="string" required>
响应值的期望类型。可以是任意字符串。
</ResponseField>
<ResponseField name="default" type="string">
默认值。
</ResponseField>
<ResponseField name="required" type="boolean">
指示该响应是否为必填。
</ResponseField>
<ResponseField name="deprecated" type="boolean">
指示该字段是否已废弃。
</ResponseField>
<ResponseField name="pre" type="string[]">
显示在字段名称之前的标签。
</ResponseField>
<ResponseField name="post" type="string[]">
显示在字段名称之后的标签。
</ResponseField>