Returning an array of objects that properly define

2019-08-04 07:11发布

I have a typical RESTful endpoint that returns a collection of models, but the generated Ruby SDK returns a new model, Matters instead of an array of models. I can hack at the generated source code to return Array<Matter> but that is a maintenance headache. How do I specify that I want to return Array<Matter> in the YAML?

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条回答
霸刀☆藐视天下
2楼-- · 2019-08-04 07:53

Figured it out...

  responses:
    200:
      description: "200 response"
      schema: 
        type: "array"
        items:
          $ref: "#/definitions/Matter"
查看更多
登录 后发表回答