openapi - 使用 Quarkus 的反应式 REST 服务的 OpenAPI 规范
问题描述
到目前为止的旅程
我正在尝试按照官方指南,使用 RESTEasy 和 JSON-B 启动并运行反应式 REST 服务。我还添加了对 OpenAPI 的支持,以按照本指南测试服务。
两个部分都独立工作,服务正确返回硬编码的演示数据。Swagger UI 显示可用的路由并允许调用它们。
然而,它并不像我喜欢的那样光滑......
从简单的非反应性路由中,模式已被正确提取:
Fruit:
type: object
properties:
description:
type: string
name:
type: string
但是从响应式路由中,已经提取了空模式。例如,引入
@GET
@Path("/{name}")
public Uni<Fruit> getOne(@PathParam(value = "name") String name) {
}
导致架构:
UniFruit:
type: object
有没有办法重用现有的Fruit
模式?
我尝试注释路线,但没有任何效果:
@GET
@Path("/{name}")
// @Schema(ref = "#/components/schemas/Fruit") // Nope...
// @Schema(ref = "Fruit") // Nope...
public Uni<Fruit> getOne(@PathParam(value = "name") String name) {
}
理想情况下,无论如何我都不想单独注释每个反应方法。
问题
有没有办法在项目范围内配置以使用T
路由返回时的模式Uni<T>
或Multi<T>
?
解决方案
同时,您可以使用注解的implementation
属性:@Schema
@GET
@Path("/{name}")
@APIResponse(
content = @Content(mediaType = MediaType.APPLICATION_JSON,
schema = @Schema(implementation = Fruit.class)))
public Uni<Fruit> getOne(@PathParam(value = "name") String name) {
}
推荐阅读
- php - 如何在php中存储2000万位大数字?
- facebook - 服务器未收到来自 Facebook Webhook 的响应
- ansible - 如何在 ansible-playbook 命令行中传递用户名和 ssh 密码 - Bamboo
- react-native - 世博会图片上传承诺拒绝 ImagePicker.launchImageLibraryAsync 错误
- amazon-web-services - 如何在 Lake Formation 蓝图中指定 s3 存储桶作为数据源
- reactjs - 口袋妖怪,API调用变量不保存
- react-native - StompJs 仅在调试模式下工作 - React Native
- php - 使用随机令牌检查 Laravel 多次点击重复数据
- r - 如何为两个 r 数据帧之间的不均匀匹配行提取二进制响应?
- mysql - 如何创建 MySQL 查询以获取每月每个日期的销售额(如日历)?