Swagger Open API 3.0.1:如何为响应示例定义对象数组

问题描述

使用 Open API 3.0.1 为 API 规范定义 swagger 定义。但是,这里定义的响应示例 GoodResponse 没有呈现。虽然语法似乎是有效的。任何关于我做错了什么的指示表示赞赏

paths:
  /java/api/play:
    post:
      tags:
        - some-controller
      operationId: someOperation
      requestBody:
        content:
          application/xml:
            schema:
              $ref: '#/components/schemas/HarryKartType'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                items:
                  $ref: '#/components/schemas/GoodResponse'
components:
  schemas:
    GoodResponse:
      required:
        - goodstatusCode
        - goodresponseMessage
      type: object
      properties:
        goodstatusCode:
          type: integer
          example: 200
        goodresponseMessage:
          type: array
          example:
            - position: 1
              horseName: "TIMETOBELUCKY"
            - position: 2
              horseName: "HERCULES BOKO"
            - position: 3
              horseName: "CARGO DOOR"
          items:
             $ref: '#/components/schemas/GoodResponseMessage'
             
    GoodResponseMessage:
      type: object
      properties:
        position:
                type: integer
                example: 1
        horseName:
                type: string
                example: "TIMETOBELUCKY"

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)