2017-06-27 290 views
0

我有一個JSON有效載荷,我需要就如何代表它在一些幫助定義了JSON輸出招搖,YAML如何使用招搖

關鍵字可以是一個空數組[]或和數組如[「A」 , 'b', 'C']

這是我的目標

{ 
    "keywords": [], 
    "distance": "25", 
    "jobType": "all", 
    "sectorId": "0", 
    "location": { 
     "lat": "33.7489954", 
     "lng": "-84.3879824", 
     "name": "Atlanta, GA" 
    } 
} 

這是我迄今爲止,但我得到的錯誤

SyntaxError: Data does not match any schemas from "oneOf" 
Data path: "/paths/~1users~1{userId}~1jobdeckSearch/get/responses/200" 
Schema path: "/properties/paths/patternProperties/^~1/properties/get/properties/responses/patternProperties/^([0-9]{3})$|^(default)$/oneOf" 


responses: 
     200: 
      schema: 
      type: object 
      properties: 
       distance: 
       type: string 
       keywords: 
       type: array 
       items: 
        type: string 
       jobType: 
       type: string 
       sectorId: 
       type: string 
       location: 
       properties: 
        lat: 
        type: string 
        lng: 
        type: string 
        name: 
        type: string 

回答

1

響應代碼需要description

 responses: 
     200: 
      description: OK 
      schema: 
      ... 

此外,latlng之前刪除多餘的空格字符 - 他們需要在同一水平name被縮進。

除此之外,你的定義是好的。