Repository navigation
fix(typescript,python,csharp,java,php,ruby,unity,mcp): derive valid member names for underscore-digit enum values #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d1eb33a
fix(enums): derive valid member names for underscore-digit enum values
AshGodfrey 7bace9f
fix(mcp): apply the digit guard to the derived enum name helper as well
AshGodfrey bd70985
fix(typescript,unity,mcp): suffix enum members that share a derived n…
AshGodfrey c4b7350
fix(validation): re-sanitize digit-leading enum names in the collisio…
AshGodfrey 84ccdb5
fix(typescript,mcp): add numericEnumMemberNames option for digits-onl…
AshGodfrey 05822d8
fix(typescript): always spell out digits-only enum members in native …
AshGodfrey 2c171f6
fix(java): derive valid names for digit-leading enum overrides and OA…
AshGodfrey bb15dc8
fix(validation): keep the enum collision validator's existing derivat…
AshGodfrey 5738a8f
test(enums): cover an x-speakeasy-enums override in the underscore-di…
AshGodfrey 8db3811
fix(typescript,mcp): keep every valid numeric literal key under legac…
AshGodfrey b7413bb
fix(java): detect enum member collisions on the emitted upper-snake name
AshGodfrey 5e444f8
test(enums): cover the _1ST + 1ST collision pair and fix it in the mo…
AshGodfrey 510b6c6
fix(typescript,python,csharp,java,php,ruby,unity,mcp,mockserver): res…
AshGodfrey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| id: 1790962042-cf634029 | ||
| features: | ||
| - enums | ||
| targets: | ||
| - csharp | ||
| - javav2 | ||
| - mcp-typescript | ||
| - mockserver | ||
| - php | ||
| - pythonv2 | ||
| - ruby | ||
| - typescriptv2 | ||
| - unity | ||
| type: fix | ||
| bump: patch | ||
| description: derive valid enum member names for values that start with an underscore followed by digits; TypeScript and MCP TypeScript add a `numericEnumMemberNames` option that spells out digits-only values such as `_1` as `One` for new SDKs and keeps the numeric key for existing SDKs with union enums (native enums always spell digits out), Java applies the same derivation to `x-speakeasy-enums` overrides and OAuth2 scope names and detects member collisions on the emitted upper-snake name, the mockserver detects them on the emitted field name, values that share a derived name receive suffixes that are checked against every other member name in the enum, and `x-speakeasy-enums` override names are disambiguated as a group the same way | ||
| author: AshGodfrey | ||
| date: "2026-10-02" |
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -116,28 +116,32 @@ function enumLiteralFromValue( | |||||
| } | ||||||
|
|
||||||
| function getEnumNamesFromValues(values: string[]): string[] { | ||||||
| let enumNames = []; | ||||||
|
|
||||||
| let names = {}; | ||||||
| for (const value of values) { | ||||||
| let name = sanitizeEnumName(value); | ||||||
| if (!names[name]) { | ||||||
| names[name] = 0; | ||||||
| } | ||||||
| return disambiguateEnumNames(values, sanitizeEnumName); | ||||||
| } | ||||||
|
|
||||||
| names[name] += 1; | ||||||
| function disambiguateEnumNames( | ||||||
| values: string[], | ||||||
| deriveName: (value: string) => string, | ||||||
| ): string[] { | ||||||
| const baseNames = values.map(deriveName); | ||||||
| const counts = new Map<string, number>(); | ||||||
| for (const name of baseNames) { | ||||||
| counts.set(name, (counts.get(name) || 0) + 1); | ||||||
| } | ||||||
|
|
||||||
| for (const value of values) { | ||||||
| let name = sanitizeEnumName(value); | ||||||
| if (names[name] > 1) { | ||||||
| name = `${name}${caser().ToPascal(getCasing(value))}`; | ||||||
| const used = new Set(baseNames.filter((name) => counts.get(name) === 1)); | ||||||
| return values.map((value, i) => { | ||||||
| let name = baseNames[i]; | ||||||
| if (counts.get(name) > 1) { | ||||||
| const candidate = `${name}${caser().ToPascal(getCasing(value))}`; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P1: Legacy mode still generates invalid members when two values share a preserved numeric name. Re-sanitize the suffixed candidate so Prompt for AI agents
Suggested change
|
||||||
| name = candidate; | ||||||
| for (let suffix = 1; used.has(name); suffix++) { | ||||||
| name = `${candidate}${suffix}`; | ||||||
| } | ||||||
| used.add(name); | ||||||
| } | ||||||
|
|
||||||
| enumNames.push(name); | ||||||
| } | ||||||
|
|
||||||
| return enumNames; | ||||||
| return name; | ||||||
| }); | ||||||
| } | ||||||
|
|
||||||
| function getEnumDataType(typeDef: TypeDef): "string" | "number" { | ||||||
|
|
||||||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.