fix(Kotlin): use the global apiNamePrefix and apiNameSuffix settings instead of apiSuffix (generator's option)
Merged
MA
5mo ago+17+17+01234567890123456789-20-20-01234567890123456789
fixes (#23822)
As discussed in #23834 opened PR for master aswell as the change has a fallback.
Removes Kotlin specific apiSuffix additionalSetting.
Adds support for global apiNamePrefix and apiNameSuffix settings to the kotlin generator.
PR checklist
- Read the contribution guidelines.
- Run the following to build the project and update samples:
(For Windows users, please run the script in WSL)./mvnw clean package || exit ./bin/generate-samples.sh ./bin/configs/*.yaml || exit ./bin/utils/export_docs_generators.sh || exit
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example./bin/generate-samples.sh bin/configs/java*.
IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed. - If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Kotlin comittee members:
@karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) @stefankoppier (2022/06) @e5l (2024/10) @dennisameling (2026/02)
Summary by cubic
Kotlin generators now use the global apiNamePrefix and apiNameSuffix for API class names, replacing the Kotlin-only apiSuffix. Default behavior is unchanged: classes end with Api, and empty names produce DefaultApi.
-
Bug Fixes
AbstractKotlinCodegen.toApiNamenow builds names as prefix + camelized name + suffix; empty names returnDefaultApi.- Removed
apiSuffixacross the codebase (includingCodegenConstants, generator options, docs, and tests). Added tests for prefix, suffix, and prefix+suffix.
-
Migration
- Replace
-DapiSuffix=Foowith-DapiNameSuffix=Foo(and-DapiNamePrefix=Barif needed). No change if you use the defaultApisuffix.
- Replace