The Cadl named union:
model Cat {
meow: int32;
};
model Dog {
bark: string;
};
union Pet { cat: Cat, dot: Dog }
will be rendered in by the openapi3 emitter as a "oneOf" schema with discriminator"
"components": {
"schemas": {
"Pet": {
"type": "object",
"properties": {
"kind": {
"type": "string"
}
},
"required": [
"kind"
],
"discriminator": {
"propertyName": "kind",
"mapping": {
"cat": "#/components/schemas/Cat",
"dog": "#/components/schemas/Dog"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/Cat"
},
{
"$ref": "#/components/schemas/Dog"
}
]
},