I have a field in our data with multiple typing:
It could be type=string, which has the schema:
{"mixed_field" : {"type":"string"} }
Other times it could be type=object, the schema looks like:
{"mixed_field" : {
"properties": {
"access_token": {
"type": "string"
},
"created_at": {
"type": "integer"
}
},
"type": "object"
}
}
How do I express that "mixed_field" can be either type string or type object? Should I use the "oneOf" keyword as follows?
{
"mixed_field": {
"oneOf": [
{
"type": "string"
},
{
"properties": {
"access_token": {
"type": "string"
},
"created_at": {
"type": "integer"
}
},
"type": "object"
}
]
}
}
You can use oneOf/anyOf or you can use
"type": ["string", "object"]
, in case it is a string "properties" keyword will be ignored.