https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
e

eygraber

03/01/2024, 5:29 AM
Any good OpenAPI generators out there for KMP? Bonus points for wasmJs support!
h

hfhbd

03/01/2024, 6:09 AM
Didn’t try, we have our own, but there are existing Ktor client and server generators.
j

Jeff Lockhart

03/01/2024, 6:11 AM
I've used this one. It should work for KMP with
library = multiplatform
,
serializationLibrary = kotlinx_serialization
, and
dateLibrary = kotlinx-datetime
.
e

eygraber

03/01/2024, 6:46 AM
Thanks! @Jeff Lockhart how was the quality of the plugin and the generated code?
j

Jeff Lockhart

03/01/2024, 7:06 AM
I found the generated code satisfactory for the API I used it with. I ran into a few hiccups, but most I was able to fix in the spec definition. I ended up using Jackson for serialization, since I didn't need KMP support. I can't recall why I switched from kotlinx-serialization though. It might have just been easier to do something.
I never got the code generation fully configured as part of my project's build. It generates an entire Gradle parent project. I ended up having to manually fix a generic type error in one of the APIs and also fixed some duplicate classes (the code worked as it was, but was redundant). Since my API doesn't change often, I just added the generated code with my fixes to my own source code instead of having it generate on each build.
11 Views