Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
This branch has not been deployed
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.
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
@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim
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.Written for commit 84530c6. Summary will update on new commits.