fix(typescript): do not import enum literals of anyOf params as models #25670
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.45) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 434 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.363
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #25670"
general
weight: 0.35
thekhegay
Since
SIMPLIFY_ONEOF_ANYOF_ENUM(on by default) turns anyOf of enum refs into one inline enum, param type becomes literal union like'value1' | 'value2'.toModelImportMapsplits it on|and every member passesneedToImport, so api file getsimport { 'value1' } from ...(fetch alos html-escapes it to'value1'), integer enums giveimport { 1 } from '../models/1'. Generated client does not compile. Not an escaping issue, these imports should not be there at allneedToImportinAbstractTypeScriptClientCodegennow skips literal members (quote anywhere, or leading digit), they are never model names. Fixes typescript-fetch, typescript-angular, typescript-node and typescript, all of them go through this methodAdded test in
TypeScriptFetchClientCodegenTestwith string and integer enums, it fails on master, other typescript tests pass. Regenerated all 93 typescript configs, no sample changes. For the issue spec generated fetch client passestsc --strict, on master it gives 90 errorsFixes #22682
PR checklist
Commit all changed files.
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim
<!-- This is an auto-generated description by cubic. -->
---
Summary by cubic
Fixes TypeScript code generators emitting broken model imports for inlined enum literal values. When
anyOfcombines enum schemas,SIMPLIFY_ONEOF_ANYOF_ENUMinlines them into literal unions, so the generated API file previously gotimport { 1 } from '../models/1'or an HTML-escaped'value1'import, neither of which compiles. Fixes #22682.Bug Fixes
needToImportinAbstractTypeScriptClientCodegennow skips unions whose members are all literal values; a model next to a literal in a union is still imported.TypeScriptFetchClientCodegenTestcovering string and integer enums and the mixed literal-with-model union; generated samples for all 93 TypeScript configs are unchanged.<sup>Written for commit 84530c67688f8527e785742dbdb61151209d9723. Summary will update on new commits.</sup>
<a href="https://cubic.dev/pr/OpenAPITools/openapi-generator/pull/25670?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->