I have an openapi spec where one of the objects can contain only one of 2 ids: type1 id or type2 id. Each of these ids is just of type string. The official docs show the use of refs when using oneOf, which would suggest that they need to be an object but in my case the 2 types are just of type string.
"domainId": {
"oneOf":
[
{
"$ref": "#/components/type1Id"
},
{
"$ref": "#/components/type2Id"
}
]
},
"components":
{
"type1Id":
{
"type": "string"
},
"type2Id":
{
"type": "string"
}
}
Is this the best way of defining it?