papsign / Ktor-OpenAPI-Generator

Ktor OpenAPI/Swagger 3 Generator
Apache License 2.0
241 stars 42 forks source link

Support for Ktor 2.0.0 #128

Open Marek00Malik opened 2 years ago

Marek00Malik commented 2 years ago

Hey, When can we count on support for the new Ktor release -> 2.0.0 ? I'm not able to install the OpenAPIGen plugin.

vladtrc commented 2 years ago

In my opinion such functionality should already be built in...

Wicpar commented 2 years ago

i don't work with Ktor anymore, i can't spare the time for such a rework, however i will accept pull requests...

LukasForst commented 2 years ago

Hey, I forked this repo and wired stuff together to work with Ktor 2.0.0 the fork is here - https://github.com/LukasForst/ktor-openapi-generator - it's also deployed on maven central, so feel free to use that build.

It's not very nice, Ktor removed some stuff this lib relied on (content type handling for example see this ugly hack ) but I monkey patched most of the stuff and now I'm successfully using that in two of my projects in production with Ktor 2.0.0 - so I guess the subset of stuff I use works.

There're are definitelly better ways how to fix all that stuff to make it compatible with Ktor 2.0.0, I choose the way of minimal effort and that's why I didn't make PR to this repository. I'm not sure if we can upstream this to master here as during the process I also migrated to gradle kotlin DSL and I'm not sure what plans does @Wicpar have with this project.

Wicpar commented 2 years ago

@LukasForst if you are willing to maintain the project i can add you as a collaborator, and it would be a good idea to update to the newer version, even if it's a bit hacky

Marek00Malik commented 2 years ago

Hey @LukasForst I'm trying out your fork actually now. The sad part is that there is no support for Location API which looks like the way Ktor is heading (I saw an issue even raised, but it got closed... #70). Are you @LukasForst planning to play with it? I know there is a repo called kompendium that is supporting it, but they are not on Ktor 2.0.0 yet.

sigmanil commented 2 years ago

@LukasForst Are you using StatusPages in your applications with your fork? I'm trying out your fork and I seem to have some trouble with statuspages (exception handling) in tests. It's a bit weird, the tests have gone unstable, the status pages set up using the OpenApiGen withApi syntax seem to trigger only sometimes.

Edit: There's definately something strange happening with the StatusPages in the LukasForst fork, I removed the OpenApiGen status pages and relied only on base Ktor StatusPages for 2.0.0, and now it works.

LukasForst commented 2 years ago

hey @sigmanil can you try to update to latest Ktor 2.0.1? See https://youtrack.jetbrains.com/issue/KTOR-4187 because that was for example problem in my apps

actually, I'm surprised base ktor status pages work for you in 2.0.0 because according to that Ktor bug, it was broken (and it was broken in my services as well)

anyway, I'm going to release version with Ktor 2.0.1, let us know if that fixes the behavior of status pages in this library or not https://github.com/LukasForst/ktor-openapi-generator/pull/2

LukasForst commented 2 years ago

@Wicpar I'd like to, but definitely not now (busy on other projects, maybe during summer? I'll let you know). However, there're some rumours that JetBrains will work on Ktor Swagger as well (the issue has moved to "in progress" and see blog ) so maybe we will get native support. That would definitely be nice.

LukasForst commented 2 years ago

@Marek00Malik sorry, but right now, I don't have enough time to work on this, I just ported the basic stuff to keep my own service up and running and it is ugly hack anyway. Maybe I will get some time during summer, but unfortunately I can not guarantee anything.

LukasForst commented 1 year ago

looks like we're going to get official support after all - https://youtrack.jetbrains.com/issue/KTOR-774 - issue just changed from Open to In Progress

darkxanter commented 1 year ago

It looks like this library is still relevant as JetBrains makes OpenAPI spec generation a paid feature of IDEA Ultimate.

LukasForst commented 1 year ago

I agree, their solution is far from optimal. I guess we offload serving the UI to their implementation, but honestly even that one is worse, because it fetches js from remote source during runtime...

Anyway, there are now more alternatives in the wild such as https://github.com/bkbnio/kompendium and https://github.com/SMILEY4/ktor-swagger-ui

My fork of this repo is not exactly maintained, but I keep releasing dependency updates to maven central.

Wicpar commented 1 year ago

My fork of this repo is not exactly maintained, but I keep releasing dependency updates to maven central.

well this library isn't either, so if you want i can link to your repo in the readme for 2.0 compat.