• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

utybo/Koa:

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

utybo/Koa

开源软件地址:

https://github.com/utybo/Koa

开源编程语言:

Kotlin 100.0%

开源软件介绍:

koa - Kotlin and Ktor OpenAPI

Koa intends to be a fully functional DSL for OpenAPI in Kotlin, including a Ktor plugin to add OpenAPI to your server Kotlin applications.

install(Koa) {
    title = "Koa example"
    description = "Ktor + OpenAPI (+ Swagger UI) = Koa!"
    version = "1.2.3"
}

install(KoaSwaggerUi) // Optional, you can remove it if you only want to serve the OpenAPI document

routing {
    get("/hello/there") {
        // do some complicated stuff...
    } describe {
        summary = "I am an endpoint!"
        description = "This is my endpoint. It's pretty nice, isn't it?"
        200 response "application/json" {
            description = "This is a successful response."
            schema(SomeObject(someParam = "some string"))
        }
    }
    
    // An endpoint to retrieve our OpenAPI document...
    get("/openapi") {
        call.respondOpenApiDocument()
    }
    
    // ... and an endpoint to serve Swagger UI. 
    // first parameter = path from which to serve
    // second parameter = path or URI from which OpenAPI document will be loaded
    swaggerUi("/swagger", "/openapi")
}

Experimental and very much a work in progress! Use at your own risk.

I do not currently have time to write full documentation for this, have a look at the sample (samples/ktor) for details, sorry :(

Usage

You can add the libraries via JitPack.

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'guru.zoroark:koa:main-SNAPSHOT'
    implementation 'guru.zoroark:koa-ktor:main-SNAPSHOT'
    implementation 'guru.zoroark:koa-ktor-ui:main-SNAPSHOT'
}

The following modules are present:

  • koa-dsl, the DSL components of Koa without any dependencies other than Swagger Core
  • koa-ktor, the Ktor feature which adds the ability to document endpoitns and serve OpenAPI documents
  • koa-ktor-ui, utility feature for Ktor that allows you to serve Swagger UI easily. Does not actually depend on koa-ktor, you can also use it as-is as long as an OpenAPI document is served from somewhere.
  • samples, sample applications
    • samples:ktor a more complete example of how you can use the koa-ktor feature.



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
acm309/PutongOJ: Putong Online Judge -- An online judge with nothing special发布时间:2022-07-09
下一篇:
lichangwei/koa-router-decorators发布时间:2022-07-09
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap