oneOf
is only special when used directly inside a schema. When you use oneOf
inside properties
, then it has no special meaning, so you actually end up defining a property called "oneOf"
instead.
Also - it's not the property definitions that make something required, it's the required
keyword. This keyword is an array of required properties (not a boolean, that's old syntax).
To do what you want, you make a oneOf
clause where one option has "station_id"
required, and the other has "station"
required:
{
"oneOf": [
{"required": ["station"]},
{"required": ["station_id"]}
]
}
If both are present, then the data will be invalid (because only one oneOf
entry is allowed to pass).