Description I have an exposed file from spring boot server and I am using this script to generate a typescript angular client
openapi-generator-cli generate -g typescript-angular -i ./src/app/data/open-api.json -o ./src/app/data/build/openapi
there are duplicated api names among the system
simple structure
Controller1 : [get,list,delete,... ....] Controller2 : [get,list,delete,... ....] .....
the generated classes looks like
Controller1Service{
public get1 ....
public list1 .....
}
Controller2Service{
public get2 ....
public list2 .....
}
but the functions are unique in the same controller and the generator still adding numbers to them
openapi-generator version 4.3.1 using npm cli
OpenAPI declaration file content or url Command line used for generation openapi-generator-cli generate -g typescript-angular -i ./src/app/data/open-api.json -o ./src/app/data/build/openapi
So any way to make these numbers disappear ?
when updating the backend the numbers may be changed inside and it will lead to a manual code refactor
From the template, the numbers come from the 'nickname' attribute.
In the internals of OpenAPI this is produced from the operationId when generating the open-api.json file.
The solution for Spring Boot (and others alike, to adapt...) is to tweak the operationId generation (original answer).
To have generated code still match a common interface (as when using generic Spring controllers), the operationId must match a reference (default: handling method name). Here is what I used (ChangeController.class being generic and making about 80% of the API).
IMPORTANT NOTE : this will generate error on the spec validation when generating the Angular client, disable validation explicitly (skipValidateSpec).
Also, for generation working with Angular 10+, openapi-generator 5.0.0 is required (for generic ModuleWithProviders).