> For the complete documentation index, see [llms.txt](https://gitbook.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.com/docs/documentation/zh/chuang-jian-nei-rong/openapi/guides/openapi-layouts.md).

# OpenAPI 布局

在 API 参考中选择按标签一页或按操作一页

插入 **OpenAPI 参考**后，GitBook 可以通过两种方式组织操作。

请选择符合用户浏览 API 方式的布局。

### 访问此设置

选择布局的步骤：

1. 在你的分区中，点击 **添加新内容...** → **OpenAPI 参考**。你也可以编辑现有的 OpenAPI 参考。
2. 选择 OpenAPI 规范。
3. 在 **页面结构**中，选择 **每个标签一个页面** 或 **每个操作一个页面**.

如需了解完整的设置流程，请参阅 [在文档中插入 API 参考](https://gitbook.com/docs/documentation/zh/chuang-jian-nei-rong/openapi/insert-api-reference-in-your-docs.md).

### 可用布局

GitBook 支持两种布局：

* **每个标签一个页面** 会为每个标签创建一个页面。每个页面会列出带有该标签的所有操作。
* **每个操作一个页面** 会为每个操作创建一个页面。GitBook 会在目录中按标签对这些页面分组。

### 示例输入

两种布局都基于相同的 OpenAPI 数据：

{% code title="openapi.yaml" %}

```yaml
paths:
  /users:
    get:
      tags:
        - users
      summary: List users
    post:
      tags:
        - users
      summary: Create user
```

{% endcode %}

### 每个标签一个页面

如果每个标签都代表 API 中一个明确的版块，请使用此布局。

如果你需要概览页面、更精简的导航，以及在同一页面上展示相关端点，此布局会很适合。

使用此布局时，这两个操作会显示在为 `users` 标签生成的同一个页面上。

### 每个操作一个页面

如果你希望用户能直接链接到各个端点，请使用此布局。

此布局适用于大型 API，或需要在导航中为每个端点单独创建页面的情况。

使用此布局时，GitBook 会为 `GET /users` 创建一个页面，并为 `POST /users`创建一个页面。这两个页面都会显示在 `users` 标签组下。

### 快速建议

对于较小的 API，或每个标签都代表一个明确版块的情况，建议选择 **每个标签一个页面** 。

选择 **每个操作单独一页** 适用于较大的 API，或需要为每个端点单独创建页面的情况。

### 控制生成的导航

在这两种布局中，GitBook 都会使用 OpenAPI 标签来组织参考文档。

如需控制顺序、层级、页面标题、图标和描述，请参阅 [组织 API 参考文档](https://gitbook.com/docs/documentation/zh/chuang-jian-nei-rong/openapi/guides/structuring-your-api-reference.md).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://gitbook.com/docs/documentation/zh/chuang-jian-nei-rong/openapi/guides/openapi-layouts.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
