返回正确定义SDK响应的对象数组

时间:2017-07-18 19:09:24

标签: swagger swagger-2.0 swagger-codegen

我有一个典型的RESTful端点,它返回一组模型,但生成的Ruby SDK返回一个新模型,Matters而不是模型数组。我可以破解生成的源代码返回Array<Matter>,但这是一个维护问题。如何指定我想在YAML中返回Array<Matter>

paths:
  /matters:
    get:
    ...
    responses:
      200:
        schema:
          $ref: "#/definitions/Matters"
...
definitions:
  Matter:
    type: "object"
    properties:
      id:
        type: "string"
        description: "Database identifier of the object."
      caseId:
        type: "string"
        description: "Database identifier of the Case object."
      clientMatterNumber:
        type: "string"
        description: "Client/matter billing code."
      judge:
        type: "string"
        description: "Initials of the presiding judge."
      caseNumber:
        type: "string"
        description: "Canonical case number."
      caseTitle:
        type: "string"
        description: "Canonical case title."
      natureOfSuit:
        type: "string"
        description: "Judicial Conference designation of the case."
      docketEntries:
        type: "integer"
        description: "The count of docket entries in the case."
      activityAt:
        type: "string"
        format: "date-time"
        description: "The time of last activity in the case. "
  Matters:
    description: "A collection of matters"
    type: "array"
    items:
      $ref: "#/definitions/Matter"

1 个答案:

答案 0 :(得分:5)

想出来......

  responses:
    200:
      description: "200 response"
      schema: 
        type: "array"
        items:
          $ref: "#/definitions/Matter"