下面定义了json架构。我已经测试了anyOf,oneOf,allOf。架构在除了oneOf之外的所有情况下都能正常工作。理想情况下,它应该只在一个工作。它不起作用。
{
"bsonType": "object",
"additionalProperties": true,
"properties": {
"_id": {},
"enhanced_file_url": {
"bsonType": "string"
},
"child_docs": {
"type": [
"array"
],
"items": {
"bsonType": "object",
"additionalProperties": true,
"properties": {
"_id": {},
"standardized_data": {
"oneOf": [
{
"bsonType": "object",
"properties": {
"shipper__address_line_1": {
"bsonType": "string"
}
}
},
{
"bsonType": "object",
"properties": {
"shipper__address_line_2": {
"bsonType": "double"
}
}
}
]
},
"standardized_field_prediction": {
"bsonType": "object",
"additionalProperties": true
}
}
}
}
}
}
以下是json数据的输入格式。
{
"enhanced_file_url" : "http://localhost:9000/documents/5ab51e99534b44180e0bdb0c/document_download",
"child_docs" : [
{
"standardized_data" : {
"shipper__address_line_1": "A28 pariseema Complex"
}
},
{
"standardized_data" : {
"shipper__address_line_2": "A1-63 Orchid Greenfield"
}
}
]}
当我们运行上面的架构时,它会给出错误