papsign / Ktor-OpenAPI-Generator

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

Comparison to ktor-swagger #4

Open Globegitter opened 4 years ago

Globegitter commented 4 years ago

Hi, I just saw this project and it looks very, very interesting. I am trying to figure out how this project differs to https://github.com/nielsfalk/ktor-swagger

Does this have any features the other one does not have, or is it simply different api, etc?

ganeshmahajan1985 commented 4 years ago

Hi @Globegitter ,

This might not be the exact answer you are looking for. I choose this over nielsfalk's because the project status he mentioned - "This project is a proof of concept built on a library to support this functionality."

So I thought to give this one a try instead of that.

Couple of times I have raised some issues as well on this and developer is very responsive he helped out me quickly. So far I am happy with things offer by this library.

Cheers!

Wicpar commented 4 years ago

Hi, I just saw this project and it looks very, very interesting. I am trying to figure out how this project differs to https://github.com/nielsfalk/ktor-swagger

Does this have any features the other one does not have, or is it simply different api, etc?

Hi,

It actually started with me using ktor-swagger, and being dearly disappointed. All metadata had to be generated per endpoint, with an ugly and encumbering syntax get<pets>("all".responds(ok<PetsModel>())) instead of get<pets, PetsModel> that you would use here.

I came from the spring framework and it was a shame that that library didn't leverage the annotations system for metadata. All reflection is computed when building the routes during initialisation, and it allows for extremely reusable code as the DTO carries the metadata with @Request and @Response.

I then evolved the system beyond that with a truly modular system that allows anyone to extend it (documentation pending, but you can look at how exception handling metadata is done with throws(apiException<ExceptionClass>(transformerFun)) as an example) Not only will the route be built, but the OpenAPI metadata will be contextually added.

All other features are cited in the readme, it may not be very exhaustive or detailed, but i will gladly write a wiki page on how to use them if it is requested.

But one of the latest features that truly shines is transformers and validation, built to be the equivalent of Spring's javax validation. Just annotate the Property object's parameter with @ToLowerCase for instance, and the parameter will automatically be forced to lower case. The transformers are computed during route building so you should see minimal performance impacts compared to the equivalent on Spring.

I hope the project can evolve and become even more convenient, some aspects require a little polishing, like the generated DTO definitions when containing arrays and Lists, or other OpenAPI definition aspects that might need to be reworked for optimal extendability.

Globegitter commented 4 years ago

Thanks for both of your responses, that has been convincing enough and I will give this here a try now :)

DrewKiino commented 4 years ago

this library is amazing btw, Ktor is a really great modular library and having swagger support was one of the bigger issues. this pretty much solved it for me. hopefully this library gets continued support so it be used in production apps more.