I know official swagger support is on the horizon ...
# ktor
t
I know official swagger support is on the horizon but, in the mean time, I made this plugin to generate route definitions automatically https://github.com/tabilzad/ktor-docs-plugin
👀 1
👍 2
l
I know that https://github.com/bkbnio/kompendium already exists, but hasn’t been updated to Ktor 2.0, just out of curiosity, have you considered contributing 2.0 support to that? Not trying to suggest not making a new version, just trying to see if taking something that already exists would make things quicker.
t
kompendium seems to require changing your existing code and wrapping route definitions with the notarized DSL. I wanted a simple plug and play solution that doesn't require any code changes whatsoever - you just annotate your routes with
@KtorDocs
and it automatically parses your code and generated openspec
l
Sounds good. Can’t wait to see the progress on this.
t
Depending on how jetbrains will provide support for this I might eventually consider contributing this as a feature to kompendium
l
I wouldn’t hold my breath on official support. JetBrains has a tendency to keep new products in alpha/beta for a long time so they can remove bugs and find the ‘best’ public API. It leads to better products in the end, but a very long wait time.
It mainly depends on if they see Swagger support for Ktor as a major feature that needs to be thoroughly designed and tested or as a small convenience.
r
I didn't have time to take a closer look at the code. But your description seems promising. How does it work then? I saw some arrow-meta imports. Can you analyze code at function level and thereby infer the OpenAPI spec? I'm wondering because you want to omit the wrapper DSL.
d
Looks very promising 😍
t
yep, it goes through your code expressions and figures out open api spec based on function params, invocations, etc.
l
How do you handle descriptions of parameters?
Also, I believe Swagger supports text descriptions of properties of types at the bottom. Can this be done via kdocs?
t
path or query param descriptions aren't supported yet, but i have an experimental feature to also walk through your request type - so description can be done through annotation processing at class definition level. For path or query params - will have to come up with something creative 🙂