gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 00:15:03 26 4
gpt4 key购买 nike

按规范:

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

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

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

最佳答案

几个例子:

  • Swagger UI 使用标签来 group显示的操作。例如,Petstore demo有三个标签 - pet , storeuser .
  • Swagger Codegen使用标签 groups endpoints into the same API class file :

    For example, an endpoint with the "store" tags will be generated in the StoreApi class file.



  • 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

    关于rest - OpenAPI 中标签的确切用途以及它们为何独一无二,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53517210/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com