what's the best way of generating an openapi spec ...
# ktor
r
what's the best way of generating an openapi spec at build time? the IDE generated yaml is fine, but we ideally want to get it working as part of the build
a
Not aware of any build-time tools. I believe Kompendium is done at runtime
r
correct (I'm the maintainer of kompendium) Hypothetically, you could do this at build time using KSP, I have an issue open to track this here. I don't have the time to try to implement this currently, but if you want to take a stab at it, would love the contribution.
i suppose, as a hack... you could run a process in your CI pipeline to run your app, and then just curl the spec... but 😬 that feels wrong
a
A little bit, but it could work quite well. Could have a junit test spit the content out to a file, and then have a script copy it to a resource directory.
r
maybe i'm asking too specific of a question, also 🙂 - we're looking for the shortest path to generating a typescript client + models from the kotlin api. (we were planning on using https://github.com/OpenAPITools/openapi-generator once we had the spec)
r
frontend scares me, can't help u there 😰
a
I'd like to get http4k's spec generation to be done at build-time, but didn't want to touch gradle plugins. Maybe it can all just be done with ksp though; just like Kotshi.
There are usually some gotchas when using openapi-generator, but you can often get very usable clients from it.
r
I wrote a client generator (but for kotlin, using gradle) https://github.com/bkbnio/skribe It's very proof of concept at the moment, but i did use it to generate multiplatform kotlin code, for a native CLI. Hypothetically... you could use kotlinJS to generate TS code? If you do successfully do that let me know, cuz i have no idea if it'll work haha
a
Shortest path to TS would most likely be with the openapi generator though,
r
definitely... i don't recommend using my tool at all... only if you wanna get a little wild 🤠
🙃 1