OpenAPI 中标签的确切用途以及它们为何独一无二

Exact purpose of tags in OpenAPI and why are they unique

按规格:

https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md

规范使用的带有附加元数据的标签列表。标签的顺序可用于通过解析工具反映它们的顺序。并非操作对象使用的所有标签都必须声明。未声明的标签可以随机组织或根据工具的逻辑组织。列表中的每个标签名称必须是唯一的。

这些标签在解析器中是如何使用的,你能提供一些例子吗? 还有为什么需要独一无二?

举几个例子:


And also why need to be unique?

标签名称必须是唯一的,因为您不能有两个名称相同的标签。

# Correct
openapi: 3.0.2
tags:
  - name: pet    # <--- unique tag name
    description: Operations to manage the pets

  - name: store  # <--- unique tag name
    descriptions: Access to Petstore orders


# Wrong
openapi: 3.0.2
tags:
  - name: pet
  - name: pet