【发布时间】:2016-08-04 21:47:26
【问题描述】:
以下是我的 json 架构的部分版本。我目前正在使用json-schema Gem 来验证以下(部分)架构:
{
"$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”。那么我在这里缺少什么?
【问题讨论】:
标签: ruby-on-rails json rspec jsonschema