springdoc-openapi:如何在 coRouter DSL 中使用@RouterOperation
springdoc-openapi: How can I use @RouterOperation in coRouter DSL
我在 Kotlin 和 WebFlux.fn 中使用 springdoc-openapi。
我想在 CoRouterFunctionDsl 中的每个路径上使用 @RouterOperation 注释,但我不能。
@Configuration
class UserRouter(private val userHandler: UserHandler) {
// @RouterOperations annotation works here.
@Bean
fun userRouter = coRouter {
("/v1").nest {
// I want to use @RouterOperation annotation here.
GET("/users", userHandler::getUsers)
// I want to use @RouterOperation annotation here.
GET("/users/{userId}", userHandler::getUserById)
// I want to use @RouterOperation annotation here.
POST("/users", userHandler::postUser)
}
}
}
似乎没有关于此的任何相关文档。
如何在 coRouter DSL 中使用@RouterOperation?
相同的原则适用于 Kotlin DSL (coRouter):CoRouterFunctionDsl Bean 是 RouterFunction 的实例。
这是一个示例语法:
@FlowPreview
@Bean
@RouterOperations(
RouterOperation(path = "/test", method = arrayOf(RequestMethod.GET), beanClass = ProductRepositoryCoroutines::class, beanMethod = "getAllProducts"),
RouterOperation(path = "/test/{id}", method = arrayOf(RequestMethod.GET), beanClass = ProductRepositoryCoroutines::class, beanMethod = "getProductById"))
fun productRoutes(productsHandler: ProductsHandler) = coRouter {
GET("/test", productsHandler::findAll)
GET("/test/{id}", productsHandler::findOne)
}
我在 Kotlin 和 WebFlux.fn 中使用 springdoc-openapi。
我想在 CoRouterFunctionDsl 中的每个路径上使用 @RouterOperation 注释,但我不能。
@Configuration
class UserRouter(private val userHandler: UserHandler) {
// @RouterOperations annotation works here.
@Bean
fun userRouter = coRouter {
("/v1").nest {
// I want to use @RouterOperation annotation here.
GET("/users", userHandler::getUsers)
// I want to use @RouterOperation annotation here.
GET("/users/{userId}", userHandler::getUserById)
// I want to use @RouterOperation annotation here.
POST("/users", userHandler::postUser)
}
}
}
似乎没有关于此的任何相关文档。
如何在 coRouter DSL 中使用@RouterOperation?
相同的原则适用于 Kotlin DSL (coRouter):CoRouterFunctionDsl Bean 是 RouterFunction 的实例。
这是一个示例语法:
@FlowPreview
@Bean
@RouterOperations(
RouterOperation(path = "/test", method = arrayOf(RequestMethod.GET), beanClass = ProductRepositoryCoroutines::class, beanMethod = "getAllProducts"),
RouterOperation(path = "/test/{id}", method = arrayOf(RequestMethod.GET), beanClass = ProductRepositoryCoroutines::class, beanMethod = "getProductById"))
fun productRoutes(productsHandler: ProductsHandler) = coRouter {
GET("/test", productsHandler::findAll)
GET("/test/{id}", productsHandler::findOne)
}