Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails JSON架构验证失败&引用;该属性不包含必需的属性";_Ruby On Rails_Json_Rspec_Jsonschema - Fatal编程技术网

Ruby on rails JSON架构验证失败&引用;该属性不包含必需的属性";

Ruby on rails JSON架构验证失败&引用;该属性不包含必需的属性";,ruby-on-rails,json,rspec,jsonschema,Ruby On Rails,Json,Rspec,Jsonschema,下面是我的json模式的部分版本。我目前正在使用json模式Gem来验证以下(部分)模式: 针对以下(部分)json: 在严格模式下进行验证时,它会声明“属性“#/botSettings/welcomessage”不包含必需的“image”属性,但是我只将必需的属性设置为“body”。那么我在这里错过了什么 你没有遗漏任何东西。标准JSON模式验证器应该认为您的JSON有效。验证失败可能是验证器中的错误、验证器中的一些非标准行为(检查配置),或者它没有按照您认为的模式进行验证(缓存问题) {

下面是我的json模式的部分版本。我目前正在使用
json模式
Gem来验证以下(部分)模式:

针对以下(部分)json:


在严格模式下进行验证时,它会声明“属性“#/botSettings/welcomessage”不包含必需的“image”属性,但是我只将必需的属性设置为“body”。那么我在这里错过了什么

你没有遗漏任何东西。标准JSON模式验证器应该认为您的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" }
      }
    }
  }
}
{
  "botSettings": {
    "welcomeMessage": {
      "title": "Welcome to the bot",
      "body": "This is the body right here"
    }
  }
}