bkbnio / kompendium

Ktor OpenAPI Spec Generator
https://bkbn.gitbook.io/kompendium
MIT License
153 stars 24 forks source link

Locations support #104

Closed mkotsbak closed 2 years ago

mkotsbak commented 2 years ago

Hi!

Have you considered how support for Locations: https://ktor.io/docs/locations.html could be added to Kompendium?

brizzbuzz commented 2 years ago

Oh wow this must be new, I see it's marked as experimental. Quite honestly, this breaks some of the stuff I had planned for kompendium v2, but I absolutely want to support this!

I'm in the process of trying to leverage KSP to generate type safe accessors for not just path params like they do here, but for all params, request body and response type.

Will need to think about how locations could fit into that model.

Thanks for the heads up!

brizzbuzz commented 2 years ago

hmm doesn't look new at all actually... surprised I've never heard of this plugin.

I'm wondering if this should be considered the default way to define parameters for Kompendium 🤔 Basically, this exactly emulates what I am trying to achieve in regards to parameters, but with a native API. And at least some level of type safety, though I do wish it was extended to request bodies and response types as well.

mkotsbak commented 2 years ago

Well, it is still experimental, so users should not at all be required to use it. It's probably so different API that extra methods for this needs to be added.

brizzbuzz commented 2 years ago

Yea ur definitely right. I need to dig into how exactly these locations work, hopefully it can just be as simple as adding a new case to the kompendium path calculator. Hypothetically, then users could use the location api in conjunction with the kompendium path annotations and life should be good.

But I'm not super hopeful that it will be that simple. Particularly because of that snazzy "nested location" thing they support.

brizzbuzz commented 2 years ago

I think we are going to be able to do this is a non-breaking way :)

I have a draft PR out that I have only tested anecdotally, but the initial pass looks decent. There are definitely some concessions that need to be made.

I am going to need to require that users add the KompendiumParam annotation to their parameters in the data class as they do for kompendium core, as that is fundamental to the way that metadata processing currently operates. Perhaps in V2 we will need to modularize that to make support for the native apis more seamless.

Also, this PR does not currently handle nested locations, gonna chew on that later.

Check it out and lemme know what you think!

brizzbuzz commented 2 years ago

I also need to think through a way to pass through the type safe object, at the moment this implementation does not do that

Never mind this was super easy :)