Closed mateuszput closed 1 year ago
Hey
If You are using Intelij, You can create a patch file which You can upload here. If You have a test which replicates a problem it should be enough.
My first guess is that it is caused by name mapper, are you using default one NoChangeClassNameMapper
or SubstringClassNameMapper
with some configuration?
I use Lombok which generates code similar to the one from the included Intellij patch.
After build the discussed entry is in a file mode-core.ts
In the original code I have also I also filters to exclude additional code from the generated TS like: new NotJavaTypeFilter(new ContainsSubStringJavaTypeFilter("Builder"))
, but it seems that it is not needed to replicate the problem.
Thank you in advance!
Hey
I had a quick look, problem is caused by unnamed class which is introduced by builders, we don't need them in TS so you need to filter out them. Selecting classes by package is too broad in such case, if your DTOs have common base class, runtime annotation or name pattern like "
tsGenerator.setModelClassesCondition(new AndFilterOperator(
Arrays.asList(
new JavaTypePackageFilter(BaseDTO.class.getPackage()),
new NotJavaTypeFilter(
new OrFilterOperator(
Arrays.asList(
new ContainsSubStringJavaTypeFilter("Builder"),
new JavaTypeFilter() {
@Override
public boolean accept(Class javaType) {
return "".equals(javaType.getSimpleName());
}
@Override
public void explain(
Class packageClass, Logger logger,
String indentation
) {
System.out.println("skipping unnamed class");
}
}
)
)
)
)
)
);
This filter combination skips builders and unnamed classes in desired package
The filter you've sent works like a charm, thank you very much for your help!
Not sure why, but I end up with with DTO in a typescript file looking like this:
I have noticed that there are 2
TSInterface
objects in a TSModule object and one of them has an empty name (name = ""
).Also in the empty object
mappedFromJavaTypeSet
field has aname
equalpackage.subdir.SomeResponse$1
. In the other one it ispackage.subdir.SomeResponse
SomeResponse$1.class
is generated since there is inner class in the file.I investigated it more and created a patch with a test to reproduce this bug. Please let me know how can I provide it or if you would like me to send you more info.