How to set JSON Schema rule to say that exactly one of the properties have to be set and is required?
I tried various ways to solve it like:
{
"id":"#",
"required":true,
"additionalProperties":true,
"type":"object",
"properties":{
"surname":{
"id":"surname",
"required":true,
"type":"string"
},
"oneOf":[
{
"$ref":"#/definitions/station_id"
},
{
"$ref":"#/definitions/station"
}
]
},
"definitions":{
"station_id":{
"type":"integer"
},
"station":{
"type":"string"
}
}
}
But it never worked. What I need to do is to accept either station_id what is an integer or station what is a string name.
Is there a way to do that, please?