Open kamyar1979 opened 7 years ago
@kamyar1979 thanks for the suggestion. Do you have time to help contribute the new generator?
I think a good starting point is to clone one of the Java server stub generators.
Ref: Ktor
cc @jimschubert
I will be happy and proud of contributing to your valuable project. How can I start?
@kamyar1979 thank you. The overview section lists all the supported server stub generator. Which one are you most familiar with?
Another way is to start the generator from scratch similar to what we've done for PowerShell and Rust. To begin with, please create Ktor with 3 endpoints listed below:
Then based on the Ktor code, we'll start the reverse engineering process to create the generator and templates.
Ok I will start tonight! It is my work hours now! Thanks for help!
No problem. Let us know if you need any help.
When I created the Kotlin client generator, I added a new.sh script to help get the right files in place for a new generator.
./new.sh -stn Ktor
This command should generate the files for a server generator, including empty test files.
@jimschubert Your shell script failed with 'sed' error!
sed: illegal option -- r
Edit: Fixed with installing gnu sed (gsed)) on mac and changing all sed to gsed in script
Can I write my extension in Kotlin instead of java?
@kamyar1979 not at the moment as the project is based on Java.
If you don't want to code in Java, what about creating Ktor Petstore as suggested in https://github.com/swagger-api/swagger-codegen/issues/6147#issuecomment-317237440 and then we'll do the reverse engineering to create the generator and templates?
@kamyar1979 I may need to set up some checks in the script prior to execution. gsed would require a check for Darwin vs Linux in the script, while missing sed on a Mac could just fail with a requirement to install gnu core utils or gnu-sed (which is what I have installed).
You could move shared Kotlin code to an abstract base class in the same way as the C# and ASP.NET Core generators. I don't know that directly extending the client generator would work for for a server generator, although I don't think I've ever tried it.
I am doing the job of adding Ktor. Lets add Kotlin polymorphism support by creating AbstractKotlinCodegen
BTW, I am also a Haskeller! Lets add AbstractHaskellCodegen and then add ScottyServerCodegen
I'll create a separate task to track the Scotty generator
Sure! It is certainly better! And I just started by Kotlin! After completing it and merging, I will start Scotty! Thanks!
are there any news on ktor support?
@deviant-studio I think @kamyar1979 is probably too busy with other tasks. Do you have time to contribute the generator? A good starting point is https://github.com/swagger-api/swagger-codegen/issues/6147#issuecomment-317237440
I'll try to take a stab at this over the next few weeks.
See #7412. It's a very barebones implementation of the server generator.
@kamyar1979 @deviant-studio the PR by @jimschubert has been merged into master. Please pull the latest master or use the SNAPSHOT version to give it a try.
Tweet to promote the new generator: https://twitter.com/wing328/status/957190593574199296
Concerning the new kotlin-server codegen but a bit off-topic (sorry) ...
For enums, could a toString
be added that returns the custom value
? It would make it friendly for the Jackson deserializer/serializer. It's also what Swagger use to lists the possible values of an enum. More in my big comment in #7811.
I responded to your linked comment.
Description
Please add Ktor http framework support for kotlin.
Swagger-codegen version
Swagger codegen 2.2.2
Suggest a fix/enhancement
Ktor is the most sophisticated Kotlin web framework. Please add support for it.