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
规范与其他元数据一起使用的标签的列表.标签的顺序可以被解析工具用来反映它们的顺序.并非必须声明操作对象使用的所有标签.未声明的标签可以是随机组织的,也可以根据工具的逻辑来组织.列表中的每个标签名称必须唯一.
A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the Operation Object must be declared. The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique.
这些标记在解析器中如何使用,您能否提供一些示例? 还有为什么需要唯一?
How are these tags used in parsers, can you provide some examples? And also why need to be unique?.
推荐答案
两个示例:
Swagger UI uses tags to group the displayed operations. For example, the Petstore demo has three tags -
pet
,store
anduser
.
Swagger Codegen 使用标签来
例如,将在 For example, an endpoint with the "store"
还有为什么需要唯一? And also why need to be unique? 在不能使用相同名称的两个标签的意义上,标签名称必须唯一. Tag names must be unique in the sense that you cannot have two tags with the same name. 这篇关于OpenAPI中标签的确切用途以及它们为何唯一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!StoreApi
类文件中生成带有"store" tags
的端点.
tags
will be generated in the StoreApi
class file.
# 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