Collections 如何在YAML Swagger定义中将属性类型定义为字符串的列表(列表、集合、数组、集合)

Collections 如何在YAML Swagger定义中将属性类型定义为字符串的列表(列表、集合、数组、集合),collections,yaml,swagger,Collections,Yaml,Swagger,我正在为API编写一个招摇过市的定义文件。该API是用于GET请求的 /path/to/my/api: get: summary: My Custom API description: | Gets a List of FooBar IDs produces: - application/json tags: - FooBar responses: "200": description:

我正在为API编写一个招摇过市的定义文件。该API是用于GET请求的

/path/to/my/api:
  get:
    summary: My Custom API
    description: |
      Gets a List of FooBar IDs
    produces:
      - application/json
    tags:
      - FooBar
    responses:
      "200":
        description: successful operation
        schema:
          $ref: "#/definitions/MyCustomType"         


对于字符串列表,您可以描述如下:

      type: array
      items:
        type: string
参考:

例如:

  • (OpenAPI v2)
  • (OpenAPI v3)

    • 这些评论似乎都没有真正回答这个问题——如何在OpenAPI/Swagger中定义一组项

      • 字符串数组与集合不同
      • 唯一字符串的数组与集合不同
      集合本质上是未重复枚举值的数组

      给定可能的字符串值
      facebook
      pinterest
      twitter
      ,名为
      share\u type
      的字段可能包含一个或多个值,例如:

      有效

      facebook
      twitter
      facebook、twitter
      facebook、twitter、pinterest

      无效项目

      instagram
      facebook、instagram
      pinterest,pinterest

      另一个重要区别是这些值不能重复。这就是
      uniqueItems
      指令可以提供帮助的地方

      鉴于上述示例,以下是OpenAPI规范的外观:

      share\u类型:
      类型:数组
      唯一项:正确
      项目:
      类型:字符串
      枚举:
      -脸谱网
      -品特烈
      -推特
      
      给定的示例是数组/列表,set如何?从谷歌那里找不到线索
            type: array
            items:
              type: string