springdoc-openapi icon indicating copy to clipboard operation
springdoc-openapi copied to clipboard

Disable Suffixes for OperationId

Open ra-lukas opened this issue 2 years ago • 0 comments

Back in the days of SpringFox, there were several requests to be able to change and/or disable the unique suffixes appended to the operationIds. While there were a few workarounds, the option to completely disable all suffixes never materialized.

The main issue is when multiple RestControllers follow the same naming convention for methods. For example, if I have multiple getById() methods, they will receive a suffix number when generated. For example, getById() might become getById_5 as an operationId. This happens even if the different getById() methods exist in different controllers.

These suffixes become a problem when using a code generator such as openapi-generator (https://openapi-generator.tech/). Even if generating to a unique class in strongly typed language like TypeScript, the method is still named after the operationId, with the suffix. Upon subsequent compiles and deploys, that number might change, which forces the API consumers to alter their code.

I may have missed something in how to avoid this, or perhaps there is a new solution, but I feel the easiest would be to have a property to disable the unique suffix.

Links for historical context. https://github.com/springfox/springfox/issues/1224#issuecomment-441214507 https://stackoverflow.com/a/38828012/203498

ra-lukas avatar Jan 09 '24 14:01 ra-lukas