2017-07-18 68 views
1

我有一个典型的REST风格的端点返回模型的集合,但产生的Ruby SDK返回一个新的模式,而不是Matters的车型阵列。我可以破解生成的源代码返回Array<Matter>,但这是一个维护头痛。我如何指定我想在YAML中返回Array<Matter>返回对象的数组,妥善定义SDK响应

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" 
+0

你如何生成的Ruby SDK - 使用扬鞭代码生成或其他什么东西? – Helen

+0

顺便提一下,Matter模型中的属性定义是无效的。将您的规格粘贴到http://editor.swagger.io并修复错误。 – Helen

+0

海伦,是的,CODEGEN –

回答

1

想通了......

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

只是为了澄清 - 该解决方案是使用内联阵列模式,而不是定义在'definitions'数组的,对不对? – Helen

+0

是的,确切地说。 –