大量的List <Object>类型示例

时间:2019-12-09 20:11:36

标签: swagger swagger-ui swagger-2.0

我收到包含以下内容的List<Image>张图片的回复。

  {
         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

1 个答案:

答案 0 :(得分:1)

响应模式缺少包装器属性images。除此之外,您的定义是正确的。

如下更改您的Images模式:

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