I am trying to test an object that can have arbitrary keys whose values are either an object that looks like this:
{ "href": "some string" }
OR an array containing the object corresponding to the above.
Here is what I DO NOT WORK now:
{
"$schema": "http://json-schema.org/schema#",
"id": "https://turnstyle.io/schema/links.json",
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "object",
"required": "href"
},
{
"type": "array",
"items": {
"type": "object",
"required": "href"
}
}
]
}
}
Passing example:
{
"customer": { "href": "/customer/1" },
"products": [
{ "href": "/product/1" },
{ "href": "/product/2" }
]
}
Failing example:
{
"customer": { "wrongKey": "/customer/1" },
"products": "aString"
}
Is this possible, and if so, what is the correct syntax?
My guess is that this will not work, because the passing scheme in oneOf|anyOf|allOfof additionalPropertiesshould apply to all the keys underneath additionalProperties.
source
share