The following OpenAPI description
components:
schemas:
VoiceIdsOrCustomVoice:
title: Voice
description: |
A built-in voice name or a custom voice reference.
anyOf:
- $ref: '#/components/schemas/VoiceIdsShared'
- type: object
description: Custom voice reference.
additionalProperties: false
required:
- id
properties:
id:
type: string
VoiceIdsShared:
example: ash
anyOf:
- type: string
- type: string
enum:
- alloy
- ash
- ballad
- coral
- echo
- sage
- shimmer
- verse
- marin
- cedar
Results in the following TypeSpec definition after import
/** Custom voice reference. */
@summary("Voice")
model VoiceIdsOrCustomVoice {
/** The custom voice ID, e.g. `voice_1234`. */
id: string;
}
union VoiceIdsShared {
string,
| "alloy"
| "ash"
| "ballad"
| "coral"
| "echo"
| "sage"
| "shimmer"
| "verse"
| "marin"
| "cedar",
}
But should really be
/** Custom voice reference. */
@summary("Voice")
union VoiceIdsOrCustomVoice {
VoiceIdsShared,
{
id: string,
},
}
union VoiceIdsShared {
string,
| "alloy"
| "ash"
| "ballad"
| "coral"
| "echo"
| "sage"
| "shimmer"
| "verse"
| "marin"
| "cedar",
}
Interestingly enough, the following input OpenAPI description works as expected even though it's more complex.
components:
schemas:
VoiceIdsOrCustomVoice:
title: Voice
description: |
A built-in voice name or a custom voice reference.
anyOf:
- allOf:
- $ref: '#/components/schemas/VoiceIdsShared'
type: string
- type: object
description: Custom voice reference.
additionalProperties: false
required:
- id
properties:
id:
type: string
VoiceIdsShared:
example: ash
anyOf:
- type: string
- type: string
enum:
- alloy
- ash
- ballad
- coral
- echo
- sage
- shimmer
- verse
- marin
- cedar
The following OpenAPI description
Results in the following TypeSpec definition after import
But should really be
Interestingly enough, the following input OpenAPI description works as expected even though it's more complex.