我按照 v7 规范草案创建了一个 JSON 模式。架构如下所示:
{
"type": "object",
"properties": {
"songs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"composition": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"publishing": {
"type": "array",
"items": {
"type": "object",
"required": ["publisherId","territory"],
"definitions": {
"categoryList": {
"type": "object",
"properties": {
"BR": {
"type": "number"
}
}
}
},
"properties": {
"publisherId": {
"type": "integer"
},
"territory": {
"$ref": "#/definitions/categoryList"
}
}
}
}
}
},
"recordings": {
"type": "array",
"items": {
"type": "object",
"properties": {
"songVersion": {
"type": "string"
},
"album": {
"type": "object",
"properties": {
"title": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
但出现错误无法解析架构引用“#/definitions/categoryList”。路径 'properties.songs.items.properties.composition.properties.publishing.items.properties.territory',第 40 行,第 24 位。如果我省略定义部分,它会完美运行