-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
[Typescript] update addImport method (fix oneOf) #11689
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
Changes from 5 commits
4aabae3
1c18501
dbeba0f
664f5a6
b66cf72
5b9e72a
d96e3a9
de9bbd0
bbc94da
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1569,14 +1569,37 @@ protected void addImport(CodegenModel m, String type) { | |
| return; | ||
| } | ||
|
|
||
| String[] parts = type.split("( [|&] )|[<>]"); | ||
| String[] parts = splitComposedType(type); | ||
| for (String s : parts) { | ||
| if (needToImport(s)) { | ||
| m.imports.add(s); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| protected void addImport(Set<String> importsToBeAddedTo, String type) { | ||
| if (type == null) { | ||
| return; | ||
| } | ||
|
|
||
|
Member
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.
Contributor
Author
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.
Member
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. can you add tests that are directly related to your code change? i.e. tests that would fail without your change.
Contributor
Author
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. Ok |
||
| String[] parts = splitComposedType(type); | ||
| for (String s : parts) { | ||
| super.addImport(importsToBeAddedTo, s); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Split composed types | ||
| * e.g. TheFirstType | TheSecondType to TheFirstType and TheSecondType | ||
| * | ||
| * @param type String with composed types | ||
| * @return list of types | ||
| */ | ||
| protected String[] splitComposedType(String type) { | ||
| return type.replace(" ","").split("[|&<>]"); | ||
| } | ||
|
|
||
| @Override | ||
| public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.TYPESCRIPT; } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.