Standarize enums to unions#1147
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates TypeSpec model definitions to represent several formerly-enum schema types as extensible string unions, aiming to standardize “enum-like” values across the specification and allow forward-compatible unknown string values.
Changes:
- Converted multiple TypeSpec
enumdeclarations tounionshapes with a leadingstringvariant and explicit string-literal members. - Applied this standardization across several API areas (chat, files, images, videos, vector stores, moderations, responses, realtime, runs, audio).
- Adjusted some local suppressions/formatting as part of the conversion.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| specification/client/models/vector-stores.models.tsp | Converts VectorStoreExpirationAnchor to an extensible string union for the .NET client surface. |
| specification/base/typespec/videos/models.tsp | Converts video-related enums (order/model/status/size/seconds/content variant) to extensible string unions. |
| specification/base/typespec/vector-stores/models.tsp | Converts ListVectorStoreFilesFilter to an extensible string union. |
| specification/base/typespec/runs/custom.tsp | Converts a run-step file-search content type to an extensible string union. |
| specification/base/typespec/responses/models.tsp | Converts image generation output/background formats and truncation enum to extensible string unions. |
| specification/base/typespec/realtime/models_GA.tsp | Converts realtime noise reduction and tool-choice options enums to extensible string unions. |
| specification/base/typespec/moderations/models.tsp | Converts moderation category input type to an extensible string union. |
| specification/base/typespec/images/models.tsp | Converts InputFidelity to an extensible string union. |
| specification/base/typespec/files/models.tsp | Converts FilePurpose (upload purpose) to an extensible string union. |
| specification/base/typespec/chat/models.tsp | Converts ChatCompletionRole to an extensible string union. |
| specification/base/typespec/chat/custom.tsp | Converts ChatToolKind and ChatToolCallKind to extensible string unions. |
| specification/base/typespec/audio/models.tsp | Converts AudioResponseFormat and TranscriptionInclude to extensible string unions. |
Comment on lines
+90
to
+91
| union RunStepDetailsToolCallsFileSearchResultObjectContentType { | ||
| string, |
Comment on lines
+814
to
+821
| union AudioResponseFormat { | ||
| string, | ||
| json: "json", | ||
| text: "text", | ||
| srt: "srt", | ||
| verbose_json: "verbose_json", | ||
| vtt: "vtt", | ||
| diarized_json: "diarized_json", |
| enum VectorStoreExpirationAnchor { | ||
| last_active_at, | ||
| union VectorStoreExpirationAnchor { | ||
| string, |
| @@ -949,13 +949,14 @@ model ChatCompletionModalities is ("text" | "audio")[]; | |||
|
|
|||
| // Tool customization: convert to enum | |||
| tool, | ||
| function, | ||
| union ChatCompletionRole { | ||
| string, |
Comment on lines
+46
to
49
| union ChatToolKind { | ||
| string, | ||
| function: "function", | ||
| } |
| enum ChatToolCallKind { | ||
| function, | ||
| union ChatToolCallKind { | ||
| string, |
Comment on lines
+313
to
+316
| union ModerationCategoryInputType { | ||
| string, | ||
| text: "text", | ||
| image: "image", |
joseharriaga
approved these changes
May 14, 2026
joseharriaga
approved these changes
May 15, 2026
joseharriaga
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #1109