【发布时间】:2015-03-31 01:28:21
【问题描述】:
我有以下 JSON 有效负载,我正在尝试为其中一个元素添加 ENUM 类型值。
{
"firstName" : "firstName",
"lastName" : "lastName",
"systemIds" : [ {
"systemName" : "SAP",
"systemId" : "99c27c63-e0b6-4585-8675-7aa3811eb4c3"
}, {
"systemName" : "SFDC",
"systemId" : "b65abf1d-825d-4ee3-9791-02d2cdd5e6f4"
}, {
"systemName" : "MONGODB",
"systemId" : "18e50430-8589-42d6-8477-58839a8bf202"
} ]
}
这是我的架构,我在使用此网站自动生成后尝试对其进行修改。 http://jsonschema.net/#/
我在这里按照我的期望手动添加了 ENUM 类型。请更正此 SCHEMA 的问题。
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://abcd.com/schemas/customerInfo",
"type": "object",
"properties": {
"firstName": {
"id": "http://abcd.com/schemas/customerInfo/firstName",
"type": "string"
},
"lastName": {
"id": "http://abcd.com/schemas/customerInfo/lastName",
"type": "string"
},
"systemIds": {
"id": "http://abcd.com/schemas/customerInfo/systemIds",
"type": "array",
"minItems": 1,
"uniqueItems": false,
"additionalItems": true,
"items": {
"anyOf": [
{
"id": "http://abcd.com/schemas/customerInfo/systemIds/0",
"type": "object",
"properties": {
"systemName": {
"id": "http://abcd.com/schemas/customerInfo/systemIds/0/systemName",
"type": { "enum": [ "SAP", "MONGODB", "ERP", "SFDC" ] }
},"required": ["type"],
"systemId": {
"id": "http://abcd.com/schemas/customerInfo/systemIds/0/systemId",
"type": "string"
}
}
}
]
}
}
}
}
【问题讨论】:
-
好的什么有问题吗?不要让我们猜测。
-
我不确定这里出了什么问题。我是 JSON 模式创建的新手,我使用此链接来验证此 JSON 模式 - jsonschemalint.com/draft4/# 这给了我以下错误。 data.properties.* 引用的架构不匹配 [object Object]
标签: json jsonschema json-schema-validator