-
-
Notifications
You must be signed in to change notification settings - Fork 7k
[BUG][Kotlin Client] API using case other than camelCase not generated properly #2391
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG][Kotlin Client] API using case other than camelCase not generated properly #2391
Conversation
modules/openapi-generator/src/main/resources/kotlin-client/data_class_req_var.mustache
Outdated
Show resolved
Hide resolved
Thanks for the PR. I think we had similar code before but it was removed. I may be remembering another generator, so I'll need to do some investigation. If memory serves, the issue was that it removes the possibility of xml support. I'll try to do some digging tonight or tomorrow, unless someone else on the core team remembers the scenario. |
b963b1e
to
91c7bb6
Compare
91c7bb6
to
5a47c55
Compare
Please note that the Kotlin client code, only support JSON serialization and deserialization (see https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/kotlin-client/infrastructure/ApiClient.kt.mustache#L33-L68) In the case where we do choose to implement XML support (which is out of scope for this PR), I'm still having a hard time understanding how adding a Moshi (which is only a JSON serializer) annotation could prevent XML Support. I noticed the circleci tests failed because of the missing imports for the annotation. I've fixed this in a new commit plus the new line issue. |
@lemoinem I searched through history in this project and swagger-codegen, and I couldn't find the code I was remembering. It must have been an issue from another generator that I was remembering. You're correct that Moshi is JSON only, which I should've realized immediately that what I was thinking about couldn't have been related to this PR! This is good to merge once the builds pass. |
Thanks! Glad we agree! If you can confirm which output you prefer ( |
@lemoinem Sorry for taking a bit to respond. I personally prefer the oneliners, but in this case I would stick with the official Kotlin style guide: https://kotlinlang.org/docs/reference/coding-conventions.html#modifiers. Basically it says only single annotations without parameters should go on the same line, all others go above. My point previously was mainly about the additional newlines, though. In generated code, people often consider large "unconventional" spacing to be an indicator that something didn't get generated as expected. It can sometimes be a pain with mustache and newlines at the ends of files, so no worries if the whitespace remains. |
5a47c55
to
2b31621
Compare
I've fixed the templates to match the style guide for annotation (for all templates, just so it's consistent). |
Shippable failure was unrelated to this PR. I've retried the build. |
Great, thanks! |
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.sh
and./bin/openapi3/security/{LANG}-petstore.sh
if 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.x
master
.Description of the PR
Generating from a json file, if an API uses anything other than camelCase, the property names are not generated with the proper Json name. The generated code does not serialize/deserialize properly.
Adding a
@Json
annotation on the properties fixes it.