Kotlin 为科特林大摇大摆
有人对Kotlin使用过招摇工具吗 在我们的组织中,我们使用Java和SpringMVC(@RestController类)创建了大多数REST服务。我们已经使用springfox生成了Swagger API文档。swagger JSON表示还用于自动提供可搜索的服务目录,因此服务元数据的swagger格式对我们很重要Kotlin 为科特林大摇大摆,kotlin,swagger,Kotlin,Swagger,有人对Kotlin使用过招摇工具吗 在我们的组织中,我们使用Java和SpringMVC(@RestController类)创建了大多数REST服务。我们已经使用springfox生成了Swagger API文档。swagger JSON表示还用于自动提供可搜索的服务目录,因此服务元数据的swagger格式对我们很重要 一些开发团队现在开始使用Kotlin。我们正在寻找与使用springfox或其他与Kotlin相关的招摇过市库相关的建议或评论 下面是一个大摇大摆的spring boot应用程序
一些开发团队现在开始使用Kotlin。我们正在寻找与使用springfox或其他与Kotlin相关的招摇过市库相关的建议或评论 下面是一个大摇大摆的spring boot应用程序示例:
@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()
}
}
依赖关系是
compile("io.springfox:springfox-swagger2:2.7.0")
compile("io.springfox:springfox-swagger-ui:2.7.0")
如果你浏览它,它就在那里……我最近有一个类似的要求。因此,我创建了一个集成了Kotlin、Webflux和Swagger的应用程序。它提供交互式API文档和自动请求验证 请参见此处-> 验证是功能性的。它是这样使用的:
validate.request(req) {
// Do stuff e.g. return a list of names
ok().body(Mono.just(listOf("carmine", "alex", "eliana")))
}
身躯
validate.request(req).withBody(User::class.java) { body ->
// Note that body is deserialized as User!
// Now you can do stuff.
// For example, lets echo the request as the response
ok().body(Mono.just(body))
}
它利用了atlassian提供的openapi 2和3验证