Swagger-codegen: [Kotlin] Add Kotlin API client generator

Created on 15 Mar 2017  路  11Comments  路  Source: swagger-api/swagger-codegen

Description

Kotlin is a statically-typed programming language that runs on the Java Virtual Machine and also can be compiled to JavaScript source code. Its primary development is from a team of JetBrains programmers based in Saint Petersburg, Russia (the name comes from the Kotlin Island, near St. Petersburg).[3] Kotlin was named Language of the Month in the January 2012 issue of Dr. Dobb's Journal.[4] While not syntax compatible with Java, Kotlin is designed to interoperate with Java code and is reliant on Java code from the existing Java Class Library, such as the collections framework.

Ref: https://en.wikipedia.org/wiki/Kotlin_(programming_language)

If anyone from the community wants to contribute and need help to start working on the generator, please reply to let us know.

Kotlin Feature New generator help wanted

Most helpful comment

Note : Jetbrain's IDEA can transform Java code to Kotlin. The produced code is generally almost direclty usable. You just have to tweak some issues with optionals and visibility.
So it shouldn't be too much work to transform the templates from Java to Kotlin.

All 11 comments

Note : Jetbrain's IDEA can transform Java code to Kotlin. The produced code is generally almost direclty usable. You just have to tweak some issues with optionals and visibility.
So it shouldn't be too much work to transform the templates from Java to Kotlin.

@wing328 I'd like to take this up within the next month or so if nobody else wants to do it. I have an existing Kotlin client project which should be fairly easy to convert over.

@cbornet while the Java -> Kotlin conversion often "works", it is neither idiomatic or ideal. In many cases, the generated code will have horrible performance.

I'm really curious about your implementation @jimschubert, looking forward to see it. What is a branch/repo you are working on?

I haven't had a chance to start work on this yet. The past few weeks have been pretty hectic. The existing code I mentioned is private, so it can't be shared.

I'll try to find time for this over the next couple of weeks.

@jimschubert I'm just starting to learn Kotlin. As a starting point I have found this blog very useful Retrofiting on Android with Kotlin
Lets see if I can contribute to project too ...

@michaelkourlas If you'd like to work on the Kotlin generator, I can leave it to you. If you'd like help, we could work together on it.

Here's a script to get all the pieces in place for a new generator. I was going to include this in my PR for the kotlin client:

https://gist.github.com/jimschubert/d9548527b8fce41b3922d2a12abb01e7

@jimschubert Were you trying to mention @michalharakal?

yeah, sorry. I have no idea how that wrong mention happened.

Hi all, thanks @jimschubert for adding the Kotlin client generator. Please pull the latest master to give it a try.

For any feedback or suggestion, please open a new issue for tracking.

Tweet: https://twitter.com/wing328/status/869233191441227777

FYI. I'll update CI later to cover the Kotlin Petstore client.

Cool. I fixed that issue I was seeing with serialization due to the 'name' parameter of Pet objects. I also included the test I mentioned in the first PR and opened a second.

I'll open another issue to track any additional work that may be picked up by the community.

Was this page helpful?
0 / 5 - 0 ratings