-
Notifications
You must be signed in to change notification settings - Fork 238
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
Controller and interfaces with generic methods result in wrong generated client #1025
Comments
WorkaroundCreate an extension so that typescript generator ignores bridge methods: class WorkaroundExtension extends Extension {
public List<TransformerDefinition> getTransformers() {
return Arrays.asList(new TransformerDefinition(ModelCompiler.TransformationPhase.BeforeTsModel, new Transformer()));
}
@Override
public EmitterExtensionFeatures getFeatures() {
return new EmitterExtensionFeatures();
}
}
class Transformer implements ModelTransformer {
public Model transformModel(SymbolTable symbolTable, Model model) {
List<RestApplicationModel> newRestApplications = model.getRestApplications().stream().map(restApplication ->
new RestApplicationModel(
restApplication.getType(),
restApplication.getApplicationPath(),
restApplication.getApplicationName(),
restApplication.getMethods().stream().filter(it -> !it.getOriginalMethod().isBridge()).collect(Collectors.toList()))
).collect(Collectors.toList());
return new Model(model.getBeans(), model.getEnums(), newRestApplications);
}
} And configure it: public static void main(String[] args) {
Settings settings = new Settings();
settings.outputKind = TypeScriptOutputKind.module;
settings.outputFileType = TypeScriptFileType.implementationFile;
settings.jsonLibrary = JsonLibrary.jackson2;
settings.generateSpringApplicationClient = true;
settings.generateSpringApplicationInterface = true;
settings.extensions.add(new WorkaroundExtension()); //<-- here
TypeScriptGenerator generator = new TypeScriptGenerator(settings);
String result = generator.generateTypeScript(
Input.from(ConcreteController.class)
);
System.out.println(result);
} |
Having the same problem: I want to create a set of controllers for various types of entities and accompany the frontend with a generic component to handle displaying and editing them. So I have a base interface like this:
However as soon as I implement this interface in a concrete controller, I get duplicate "save" methods with this strange "$" notation. If I use your workaround, the generated code seems to be missing quite a bit. Would be really great if this issue could be solved. Please tell me if there's a way I can help. |
Ok ... I found out what was going on ... Problem was, that I was already using an extension for Axios. So I ended up with this:
And:
But I needed to also copy the two files:
From the original AxiosClientExtension package ( With these two classes (and the templates in place) I could now generate my client. Thanks for your help with the original Extension. Wouldn't have been able to finish it before Christmas Dinner otherwise ;-) Merry Christmas to all :-) |
I have a controller that inherits form a generic interface:
The controller itself is using a concrete implemenations of the interface:
This results in two different client methods generated by typescript generator:
However, in java, the controller is able to deal only with
MyDto
instances. The controller is NOT accepting an arbitraryMyInterface
instance. ThedoSomething
method is available only once - with theMyDto
parameter.How to reproduce
Main class:
Actual Result
Expected Result
The text was updated successfully, but these errors were encountered: