Ktor: Sample using Swagger

Created on 25 Jul 2017  路  8Comments  路  Source: ktorio/ktor

Would be nice to have a sample with Swagger integration. Especially I am interested whether Swagger could work with Ktor like with Spring Boot and automatically generate the API using reflection, i.e. _generate a Swagger console that reflects the API of the implementation_.

Generating code from Swagger specification is another pattern but one that usually does not work in practice beyond "Hello, World!".

Enable Ktor services to expose something like http://petstore.swagger.io, to communicate their APIs would be a key asset to Ktor.

help wanted

All 8 comments

@loxal I have added the initial implementation of a swagger codegen generator for ktor servers at swagger-api/swagger-codegen#7412. If you have some time to review it (even if just the generated outputs), I'd appreciate it any feedback.

@jimschubert implemented something for generating ktor server stubs out of existing swagger definition, right?

And @loxal asking for generating swagger from an existing ktor server.

Yes, I've setup a server stub generator for ktor. I've since moved from swagger-codegen to a community driven fork: https://github.com/OpenAPITools/openapi-generator

Our fork supports all generators using OpenAPI 2 and 3.x specs, while swagger-codegen doesn't. We've also had some contributions to the ktor generator in our fork. Please check it out and open any issues you find.

This is spec -> API and not the other way around.

@loxal I was looking for the same. And here is a nice lib, already proposed to be adopted by Ktor.
https://github.com/ktorio/ktor/issues/453

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

I'll happy to provide an example of swagger integration.

I'll happy to provide an example of swagger integration.

@allevo so please do it :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shinriyo picture shinriyo  路  4Comments

KennethanCeyer picture KennethanCeyer  路  4Comments

SimonSchubert picture SimonSchubert  路  4Comments

guenhter picture guenhter  路  4Comments

PatrickLemke picture PatrickLemke  路  3Comments