使用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"发布于 2021-06-17 18:19:02
您需要在schema中定义$ref,而不是在items中尝试以下命令:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GoodResponse'https://stackoverflow.com/questions/68012877
复制相似问题