Octri

ParamField 和 ResponseField

ParamField和ResponseField用于描述你手动编写页面中的 API 字段:字段名称、类型、位置、是否必填和默认值,并可在下方添加说明。这些文档中的每个标志和设置都用它们来呈现。

示例

limitintegerquery默认值:20

要返回的项目数量,范围为 1 到 100。

customer_idstringpath必填

要获取的客户。

mdx
<ParamField name="limit" type="integer" in="query" default="20">
  How many items to return, from 1 to 100.
</ParamField>

<ParamField name="customer_id" type="string" in="path" required="true">
  The customer to fetch.
</ParamField>

ParamField 属性

namestring

字段名称,以代码样式显示。

typestring

字段类型,显示在名称旁边,例如 string、integer 或 object[]。

instring

字段的发送位置,例如 query、path、header 或 body。作为提示显示。

requiredboolean

将字段标记为必填。填写 required 或 required="true"。required="false" 表示字段为可选。

defaultstring

调用方未提供字段时使用的值。

childrenMarkdown

标签之间的说明内容。可包含表格、列表和代码。

ResponseField

用于响应中字段的相同属性。响应字段要么存在,要么不存在,因此这里 required 的重要性较低。

next_cursorstring

将其作为 cursor 传入以获取下一页。最后一页没有此值。

mdx
<ResponseField name="next_cursor" type="string">
  Pass this as `cursor` to get the next page. Absent on the last page.
</ResponseField>
尽可能让规范为你完成这些工作

端点页面根据你的规范生成参数和响应,并会在规范变更时保持正确。手动编写的字段则不会。请链接到端点页面,而不是重复其内容,除非你要说明规范无法表达的内容。

  • 编辑端点:了解规范提供的内容,以及你可以添加的内容。
  • 代码块:用于示例请求或响应。