我想组织架构的定义部分,以将许多类似的定义分组。在下面的示例中,我有一个“ipAddress”组,其中包含“ipv4”和“ipv6”子定义。(您可以想象为标识某些区域等的 IP 范围添加更多子定义。)
{
"definitions": {
"generalType": {
"ipAddress": {
"ipv4": {
"type": "object",
"properties": {
"address": {
"type":"string",
"pattern": "^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])\\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9]?[0-9])$"
},
"generalType": {
"type": "string",
"default": "ipAddress"
},
"specificType": {
"type": "string",
"default": "ipv4"
}
}
},
"ipv6": {
"type": "object",
"properties": {
"address": {
"type":"string",
"pattern": "^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$"
},
"generalType": {
"type": "string",
"default": "ipAddress"
},
"specificType": {
"type": "string",
"default": "ipv6"
}
}
}
}
}
},
"type": "object",
"additionalProperties": false,
"required": ["ipAddress"],
"properties": {
"ipAddress": {
"oneOf": …Run Code Online (Sandbox Code Playgroud)