> ## Documentation Index
> Fetch the complete documentation index at: https://smartac-justin-client-exports.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 字段

> 使用 ParamField 和 ResponseField 组件，通过类型、默认值和验证规则为 API 请求和响应参数编写文档。

使用字段为 API 的参数与响应编写文档。字段分为两类：参数字段和响应字段。

<div id="parameter-field">
  ## 参数字段
</div>

使用 `<ParamField>` 组件为你的 API 或 SDK 定义参数。添加一个 `ParamField` 将自动添加一个 [API 操作台](/zh/api-playground/overview)。

<ParamField path="param" type="string" required>
  参数字段示例
</ParamField>

```mdx theme={null}
<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 theme={null}
<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>
