该问题的原因是Apache Camel在生成OpenAPI/Swagger文档时,不会将post请求体参数自动设置为OpenAPI/Swagger参数。但是,可以通过手动配置Apache Camel路由来将post请求体参数添加到OpenAPI/Swagger文档中。
以下是一个示例路由代码,它将在post请求的数据模型中添加参数“message”:
rest("/example")
.post("/send")
.description("Send a message")
.consumes("application/json")
.produces("application/json")
.type(Message.class)
.param()
.name("message")
.type(RestParamType.body)
.description("The message to send")
.endParam()
.to("direct:send");
from("direct:send")
.convertBodyTo(String.class)
.log("Sending message: ${body}");
在这个例子中,我们使用了“param”方法来手动设置post请求体参数,并将类型设置为“RestParamType.body”。这将显式地将参数添加到OpenAPI/Swagger文档中。现在,在运行Camel应用程序时,OpenAPI/Swagger文档将包含post请求体参数“message”。