【问题标题】:Replace Long Annotations in Kotlin替换 Kotlin 中的长注释
【发布时间】:2020-06-22 17:32:04
【问题描述】:

我正在使用 Kotlin 开发 Spring Boot。现在我想创建 API 文档,但是它们的注释很笨拙和罗嗦。

当前:

@ApiResponses(
    ApiResponse(responseCode = "200", description = "Result depending on the role of the user", content = [Content(schema = Schema(oneOf = [AdminResponse::class, UserResponse::class]))])
)
fun get(authentication: Authentication): Any {
[...]
}

我想要的样子:

@Api(
    Response(200, "Result depending on the role of the user", [AdminResponse::class, UserResponse::class])
)
fun get(authentication: Authentication): Any {
[...]
}

我可以用一些东西来存档吗?一些想法是预处理和类型别名。

【问题讨论】:

    标签: spring spring-boot kotlin annotations springdoc


    【解决方案1】:

    swagger 注释已使用多年,稳定且保证良好的结果,以符合 OpenAPI 3 规范。

    这就是说,您可以创建自己的注释并重新发明轮子...

    【讨论】:

      猜你喜欢
      • 2012-03-05
      • 2010-12-18
      • 1970-01-01
      • 2015-10-01
      • 1970-01-01
      • 2014-10-08
      • 2011-10-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多