Schema should validate following objects:
{
"md5": "11111111111111111111111111111111",
"status": "malicious",
"malware_type": "adware"
}
{
"md5": "00000000000000000000000000000000",
"status": "clean"
}
No additional property should be allowed.
Schema 1:
{
"type": "object",
"properties": {
"md5": {
"type": "string"
}
},
"additionalProperties":false,
"oneOf": [
{
"properties": {
"status": {
"type": "string",
"enum": [
"clean",
"unknown"
]
}
}
},
{
"properties": {
"status": {
"type": "string",
"enum": [
"malicious"
]
},
"malware_type": {
"type": "string"
}
}
}
]
}
Unfortunately it does not allow "status" property because : Property 'status' has not been defined and the schema does not allow additional properties
Schema 2:
{
"type": "object",
"additionalProperties":false,
"properties": {
"md5": {
"type": "string"
},
"status": {
"type": "string"
},
"malware_type": {
"type": "string",
"enum":["clean", "malicious", "unknown"]
}
},
"dependencies": {
"malware_type": {
"properties": {
"status": {
"enum": [
"malicious"
]
}
}
}
}
}
This schema does not invalidates
{
"status": "malicious"
}