【问题标题】:Swagger of List<Object> Types Example [duplicate]List<Object> 类型示例的招摇[重复]
【发布时间】:2019-12-09 20:11:36
【问题描述】:

我的回复包含List&lt;Image&gt; 图像,如下所示。

  {
         images: [
          {
            "name": "ABC",
             "content": "This is text"
          },
          {
          "name": "ABC",
          "content": "This is text"
        }
       ]
  }

YAML 文件类似于以下示例。以下YAML文件是否有效且等同于上述图片的JSON响应???

responses:
     '200':
         description: 'Request is successful.'
         schema:
           $ref: '#/definitions/Images'

definitions:
   Images:
        type: array
        items:
          $ref: '#/definitions/Image'

   Image:
      type: object
      properties:
         name:
           type: string
         content:
           type: string
      required:
          - name
          - content

【问题讨论】:

    标签: swagger swagger-ui swagger-2.0


    【解决方案1】:

    响应架构缺少包装器属性 images。除此之外,你的定义是正确的。

    如下更改您的 Images 架构:

    definitions:
       Images:
           type: object
           properties:
               images:
                   type: array
                   items:
                       $ref: '#/definitions/Image'
           required:
               - images
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-14
      • 2021-12-22
      • 1970-01-01
      • 2015-12-27
      • 1970-01-01
      • 1970-01-01
      • 2021-09-11
      • 2016-05-06
      相关资源
      最近更新 更多