[BUG] Kotlin code generator does not follow Java convention for sanitizing model names
Created by: tmeneau
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
Have you tested with the latest master to confirm the issue still exists? -
Have you searched for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
The Kotlin code generator currently sanitizes model names using the DefaultCodeGen.specialCharReplacement map, which deviates from how other code generators generate model names (such as java) and results in Kotlin model and file names being generated with unexpected words interposed: MyMinusApiMinusRequestMinusObject
.
That said, this behavior is validated in the AbstractKotlinCodegenTest tests, so I was wondering if there's any particular reason to break the convention for Kotlin? If not I'd love to submit a PR to change this!
openapi-generator version
Version 5.1.1 (master)
Steps to reproduce
- Copy the AbstractJavaCodegenTest#convertModelName tests to the AbstractKotlinCodegenTest#convertModelName tests
- Run the unit tests;
- Validate that they fail.
Related issues/PRs
- https://github.com/OpenAPITools/openapi-generator/pull/7598
- https://github.com/OpenAPITools/openapi-generator/issues/7322
Suggest a fix
This is an easy fix (replace this line with a call to sanitizeName(name)). I'm happy to submit a PR if there wasn't any particular reason to deviate from convention here!
cc @jimschubert @Zomzog (please let me know if I should be CC-ing anyone else)