Skip to content
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -5148,13 +5148,13 @@ protected void addImport(CodegenModel m, String type) {
addImport(m.imports, type);
}

private void addImport(Set<String> importsToBeAddedTo, String type) {
protected void addImport(Set<String> importsToBeAddedTo, String type) {
if (shouldAddImport(type)) {
importsToBeAddedTo.add(type);
}
}

private boolean shouldAddImport(String type) {
protected boolean shouldAddImport(String type) {
return type != null && needToImport(type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1569,14 +1569,30 @@ 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;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Contributor Author

@ksvirkou-hubspot ksvirkou-hubspot Feb 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok
I ll try to do something
but maybe it would be an example of this in the petstore and test there
I ll think over it

String[] parts = splitComposedType(type);
for (String s : parts) {
super.addImport(importsToBeAddedTo, s);
}
}

protected String[] splitComposedType (String name) {
return name.replace(" ","").split("[|&<>]");
}

@Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.TYPESCRIPT; }
}