Exact purpose of tags in OpenAPI and why are they unique

前端 未结 1 580
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-13 00:28

By Specification:

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

A list of tags used by the specification with additional metadat

1条回答
  •  情话喂你
    2021-01-13 01:32

    A couple of examples:

    • Swagger UI uses tags to group the displayed operations. For example, the Petstore demo has three tags - pet, store and user.

    • Swagger Codegen uses tags to 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?

    Tag names must be unique in the sense that you cannot have two tags with the same name.

    # 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
    

    0 讨论(0)
提交回复
热议问题