[Kotlin] Add ability to use modelNamePrefix/modelNameSuffix#2349
Conversation
| assertEquals(codegen.toModelName("name"), "Name"); | ||
| assertEquals(codegen.toModelName("$name"), "Dollarname"); | ||
| assertEquals(codegen.toModelName("nam#e"), "NamHashe"); | ||
| assertEquals(codegen.toModelName("$another-fake?"), "DollaranotherMinusfakeQuestionMark"); |
There was a problem hiding this comment.
@karismann quick question if you don't mind. Should it be DollarAnotherMinusFakeQuestionMark (capital letter A and F) instead of DollaranotherMinusfakeQuestionMark?
There was a problem hiding this comment.
@wing328 I think that's happening because of camelize, after which point we would lose context of what should be capitalized here, I would think.
See
There was a problem hiding this comment.
OK. If my memory serves me well, we've something like $prefix_$name before going through camelize to handle the case mentioned above in some other generators (e.g. Perl). We can definitely go with this implementation in Kotlin and see if that's what the user expects.
|
Tested with prefixes and suffixes, and this seems to work as expected: Prefix=JimSuffix=Cats |
jimschubert
left a comment
There was a problem hiding this comment.
Thanks for doing this up!
PR checklist
./bin/to update Petstore sample so that CIs can verify the change. (For instance, only need to run./bin/{LANG}-petstore.sh,./bin/openapi3/{LANG}-petstore.sh,./bin/security/{LANG}-petstore.shand./bin/openapi3/security/{LANG}-petstore.shif updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in.\bin\windows\.master,. Default:3.4.x,4.0.xmaster.@jimschubert (2017/09) , @dr4ke616 (2018/08)
Description of the PR
fix #1885
add some missing testcase on toModelName function in abstract Kotlin CodeGen package