2016-08-04 60 views
1

以下是我的json模式的部分版本。我目前正在使用json-schema寶石驗證以下(部分)架構:JSON模式驗證失敗...「該屬性不包含必需屬性」

{ 
    "$schema": "http://json-schema.org/draft-04/schema#", 
    "properties": { 
    "botSettings": { 
     "type": "object", 
     "properties": { 
     "welcomeMessage": { 
      "type": "object", 
      "required": ["body"], 
      "properties": { 
      "title": { "type": "string" }, 
      "body": { "type": "string" }, 
      "image": { "#ref": "#/definitions/image" } 
      } 
     }, 
     "invalidCommandMessage": { "type": "string" } 
     } 
    } 
    } 
} 

針對以下(部分)JSON:

{ 
    "botSettings": { 
    "welcomeMessage": { 
     "title": "Welcome to the bot", 
     "body": "This is the body right here" 
    } 
    } 
} 

嚴格模式驗證時,指出「財產「 #/ botSettings/welcomeMessage'沒有包含'image'所需的屬性,但是我只需要設置爲「body」。那麼我在這裏錯過了什麼?

回答

1

你不會錯過任何東西。標準的JSON模式驗證器應該考慮您的JSON有效。未能驗證可能是驗證器中的錯誤,驗證器中的一些非標準行爲(檢查配置),或者它不針對您認爲它的模式(緩存問題)進行驗證。