Skip to content

Standarize enums to unions#1147

Merged
christothes merged 2 commits into
openai:mainfrom
christothes:chriss/extensible-enums
May 15, 2026
Merged

Standarize enums to unions#1147
christothes merged 2 commits into
openai:mainfrom
christothes:chriss/extensible-enums

Conversation

@christothes
Copy link
Copy Markdown
Collaborator

@christothes christothes commented May 1, 2026

fixes #1109

Copilot AI review requested due to automatic review settings May 1, 2026 19:43
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 enum declarations to union shapes with a leading string variant 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",
@christothes christothes merged commit 6f96bb1 into openai:main May 15, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standardize extensible enums in TypeSpec as open-ended named string unions

3 participants