https://kotlinlang.org logo
Title
t

Tim Abil

06/07/2022, 5:56 PM
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
👍 2
👀 1
l

Landry Norris

06/07/2022, 7:28 PM
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

Tim Abil

06/07/2022, 7:34 PM
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

Landry Norris

06/07/2022, 7:35 PM
Sounds good. Can’t wait to see the progress on this.
t

Tim Abil

06/07/2022, 8:04 PM
Depending on how jetbrains will provide support for this I might eventually consider contributing this as a feature to kompendium
l

Landry Norris

06/07/2022, 8:11 PM
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

Ron S

06/08/2022, 7:45 AM
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

David

06/08/2022, 7:56 AM
Looks very promising 😍
t

Tim Abil

06/08/2022, 2:05 PM
yep, it goes through your code expressions and figures out open api spec based on function params, invocations, etc.
l

Landry Norris

06/08/2022, 2:06 PM
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

Tim Abil

06/08/2022, 2:12 PM
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 🙂