摇摇欲坠的Kotlin

Pau*_*son 2 kotlin swagger

有没有人用过Kotlin的招摇工具?

在我们的组织中,我们使用Java和SpringMVC(@RestController类)创建了大部分REST服务.我们使用springfox生成Swagger API文档.swagger JSON表示也用于自动提供可搜索的服务目录,因此服务元数据的swagger格式对我们很重要.

一些开发团队现在开始使用Kotlin.我们正在寻找有关使用springfox或其他swagger lib与Kotlin相关的建议或意见.

gue*_*ter 7

这是一个示例弹簧启动应用程序与swagger:

@RestController
class MyController {
    @ApiOperation(value = "doc header...", notes = "detailed doc...")
    @RequestMapping(value = "/double", method = arrayOf(RequestMethod.GET))
    fun doubleValue(number: Int) = 2 * number
}


@Configuration
@EnableSwagger2
class SwaggerConfig {
    @Bean
    fun api(): Docket {
        return Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build()
    }
}
Run Code Online (Sandbox Code Playgroud)

依赖是

compile("io.springfox:springfox-swagger2:2.7.0")
compile("io.springfox:springfox-swagger-ui:2.7.0")
Run Code Online (Sandbox Code Playgroud)

如果您浏览http:// localhost:8080/swagger-ui.html那么它就在那里......