2017-07-18 69 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

是的,確切地說。 –