Repository navigation
Label a union whose variants share a type once - #63
Merged
Merged
Conversation
UltralyticsAssistant
approved these changes
Nov 30, 2026
UltralyticsAssistant
left a comment
Member
There was a problem hiding this comment.
🔍 PR Review
Made with ❤️ by Ultralytics Actions
LGTM. The change deduplicates identical union labels while preserving their first-seen order; enum constraints remain available separately. No concrete behavioral regression found.
Member
|
🎉 The PR was merged! Thanks, @glenn-jocher, for improving API reference labels by removing duplicate union types, preserving nullable variants, and clearly parenthesizing unions inside arrays. |
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.
schemaLabeljoins the label of everyoneOf/anyOfvariant, so a union whose variants share a type but differ in their values renders the type once per variant. A field that accepts either of two string enums is labeledstring | string, and a request body with three object variants is labeledobject | object | object. The repeated type tells the reader nothing, and the values are already listed separately byschemaConstraints.This flattens nested unions into one list of distinct types, and puts a union inside an array in parentheses so the array reads correctly:
string | stringstringnumber | number | numbernumberUpdateModelResponse | object | objectUpdateModelResponse | objectstring | null | stringstring | nullinteger | integer | string[] | nullinteger | (integer | string)[] | nullA few lines in
schemaLabel, plus three assertions beside the existing label tests. The labels are display-only: the API reference and other docs consumers render them, and no generator reads them for types.Testing
bun test: 21 pass, including the new assertions (two string enums →string; nullable string inside a union →string | null; integer or array of integer-or-string →integer | (integer | string)[]).bun run typecheckandbun run lintpass.🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Updated
schemaLabelto display distinct union types once and parenthesize union types inside arrays.📊 Key Changes
oneOfandanyOflabels and removes duplicate type labels, so variants like two string enums display asstring.string | nullwhen nullable and non-nullable variants are combined.(integer | string)[].🎯 Purpose & Impact