Returning an array of objects that properly defines the SDK response

℡╲_俬逩灬. 提交于 2019-12-24 10:58:06

问题


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:


Figured it out...

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


来源:https://stackoverflow.com/questions/45175188/returning-an-array-of-objects-that-properly-defines-the-sdk-response

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!