2016-08-04 64 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有效。未能验证可能是验证器中的错误,验证器中的一些非标准行为(检查配置),或者它不针对您认为它的模式(缓存问题)进行验证。