使用標籤分組操作
您可以將 tags
清單指派給每個 API 操作。帶有標籤的操作可能會被工具和程式庫以不同方式處理。例如,Swagger UI 使用 tags
來分組顯示的操作。
1paths:2 /pet/findByStatus:3 get:4 summary: Finds pets by Status5 tags:6 - pets7 ...8 /pet:9 post:10 summary: Adds a new pet to the store11 tags:12 - pets13 ...14 /store/inventory:15 get:16 summary: Returns pet inventories17 tags:18 - store19 ...
(選擇性)您可以使用根層級的全域
tags
區段,為每個標籤指定 description
和 externalDocs
。此處的標籤名稱應與操作中使用的名稱相符。
1tags:2 - name: pets3 description: Everything about your Pets4 externalDocs:5 url: http://docs.my-api.com/pet-operations.htm6 - name: store7 description: Access to Petstore orders8 externalDocs:9 url: http://docs.my-api.com/store-orders.htm
全域標籤區段中的標籤順序也會控制 Swagger UI 中的預設排序。請注意,即使標籤未在根層級定義,也可以在操作中使用標籤。