feat: accept any string for open enum parameters - #1816
Merged
Conversation
Contributor
Greptile SummaryThe PR teaches the generator to recognize open string enums from the upgraded OpenAPI canonical model and render unrestricted string types while retaining documented enum suggestions.
Confidence Score: 5/5The PR appears safe to merge based on the currently established behavior. No blocking failure remains established; the prior TypeScript declaration issue is fixed, while the Dart thread remains unknown rather than confirmed outstanding. Important Files Changed
Reviews (7): Last reviewed commit: "(refactor): let languages own open enum ..." | Re-trigger Greptile |
ChiragAgg5k
force-pushed
the
feat/open-enum-parameters
branch
2 times, most recently
from
August 20, 2026 14:00
9343724 to
d8670e1
Compare
Consume open string enum semantics from utopia-php/openapi instead of interpreting anyOf branches in the generator. Web, Node, and React Native retain enum completions while accepting arbitrary strings; other SDKs keep their ordinary string representation and serialization.\n\nCover scalar and array parameters through generated TypeScript compilation and a Dart runtime regression.
ChiragAgg5k
force-pushed
the
feat/open-enum-parameters
branch
from
August 20, 2026 14:10
d8670e1 to
300a6a5
Compare
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.
What
An endpoint can document the values callers usually want without closing the set by declaring a parameter as
anyOfover a string enum and an enum-free string branch.The parser previously exposed the raw composite, and the generator treated it as an object. TypeScript array parameters consequently degraded to
Record<string, any>[], losing both completions and the actual string type.This PR now renders the TypeScript shape as:
The intersection prevents
stringfrom absorbing the enum, retaining completions while accepting arbitrary strings.No other generated SDK can say that without closing the set — a PHP/Dart/Kotlin/Swift enum rejects unknown values. Those languages type the parameter as a plain string and keep the documented values as optional constants:
(WebhookEvent | (string & {}))enum WebhookEvent { UserCreated = 'user.created' }stringfinal class WebhookEvent { public const USERCREATED = 'user.created'; }Stringclass WebhookEvent { static const String userCreated = 'user.created'; }Stringobject WebhookEvent { const val USERCREATED = "user.created" }Stringenum WebhookEvent { public static let userCreated = "user.created" }strenum.EnumstringHow
Shape recognition lives in
utopia-php/openapi, not this generator:utopia-php/openapi0.1.2The generator consumes
CompositeSchema::openStringEnumBranch()and keeps only language-specific behavior locally:There is no generator-side union parser or Concern class.
Test plan
The shared OpenAPI 3 fixture includes scalar and array open enum parameters.
Base::assertOpenEnumsAllowAnyString()runs as part of every existing language E2E test. For TypeScript SDKs it requires the widened enum-plus-string type. For every other SDK it requires scalar and array open enums to render exactly like equivalent unrestricted strings. This keeps the assertion centralized while applying it across the complete language matrix.Generated SDK builds continue to verify that referenced Web enums are emitted and imported correctly.
Verified locally:
vendor/bin/phpunit tests/e2e/WebNodeTest.php— 1 test, 1275 assertionsvendor/bin/phpunit tests/e2e/DartStableTest.php— 1 test, 1760 assertionscomposer refactor:checkcomposer lintcomposer lint-twigcomposer validate --strict --no-check-publishGenerated and inspected Web, Node, React Native, and Dart outputs from the fixture.