我正在使用 json-schema,并且只想允许在此文件中声明的属性通过验证。例如,如果用户在其 json 对象中传递“name”属性,则此架构将失败,因为“name”未在此处作为属性列出。
是否有一些类似于“required”的函数只允许列出的属性通过?
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Accounting Resource - Add Item",
"type": "object",
"properties": {
"itemNumber": {
"type":"string",
"minimum": 3
},
"title": {
"type":"string",
"minimum": 5
},
"description": {
"type":"string",
"minimum": 5
}
},
"required": [
"itemNumber",
"title",
"description"
]
}
我相信你需要做什么来实现这一目标已经确定additionalProperties
为假。参见规格here https://github.com/json-schema-org/json-schema-spec
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)