https://kotlinlang.org logo
Title
h

hellman

01/27/2021, 4:34 PM
I guess nobody have built a custom swagger codegen generator that can output a ktor client? 😄
c

Casey Brooks

01/27/2021, 4:49 PM
There is a Kotlin generator for OpenApi Generator, but I don’t think it’s been updated in a while (generated client uses Kotlin 1.3.61), and the quality of code it generated wasn’t very good (couldn’t configure the http client, for example). Things may have improved since I last used it about a year ago, though, so you may give it a try https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/kotlin.md
h

hellman

01/27/2021, 6:42 PM
Yep. I saw that. I wonder how much work it would be to implement something for Ktor.
c

Casey Brooks

01/27/2021, 7:51 PM
The multiplatform options will generate a client SDK based on Ktor Client. But the Ktor client itself can’t be configured at runtime with the default multiplatform implementation. It’s all based on Handlebars templates, which can be customized, but they’re horribly complex (that’s how I tried with it initially, and it kinda worked but it wasn’t very easy)
m

Matteo Mirk

01/28/2021, 9:33 AM
Yeah, only chance is to modify or create new templates…