我已经在spring-boot项目中创建了Camel Rest-DSL。现在,在大张旗鼓的实施时,当我将带有必填字段和非必填字段的多查询参数传递给非必填字段时,它并没有捕获空值字段。
我的示例代码是这样的:
================= 公共类Router扩展RouteBuilder {
@Override
public void configure() throws Exception,PredicateValidationException {
JsonDataFormat json = new JsonDataFormat(JsonLibrary.Jackson);
Exchange exchnage;
CamelContext context = new DefaultCamelContext();
restConfiguration()
.component("servlet")
.apiContextPath("/api-docs")
.contextPath("/swagger")
.apiProperty("api.title", "Sample Services")
.apiProperty("api.version", "v1");
interceptFrom().to("log:received");
rest().get("/getAppStatus?MainID={MainID}&MainID2={MainID2}&MainID3={MainID3}&MainID4={MainID4}").produces("application/json").param().name("Consumer").type(RestParamType.header).endParam()
.param().name("UserRefId").type(RestParamType.header).endParam()
.param().name("ConRefId").type(RestParamType.header).endParam()
.param().name("MainID").type(RestParamType.query).endParam()
.param().name("MainID2").type(RestParamType.query).required(false).endParam()
.param().name("MainID3").type(RestParamType.query).required(false).endParam()
.param().name("MainID4").type(RestParamType.query).required(false).endParam()
.description("Get Application Status")
.to("direct:getAppStatus");
from("direct:getAppStatus").bean(idGen)
.log("body before is : ${body}")
.setHeader("operationName",constant("getAppStatus"))
.process(new GetRequestProcessor())
.setHeader("Content-Type", constant("{{route.ContentType}}"))
.setHeader("SOAPAction", constant("{{route.getAppStatus}}"))
.log("body after is : ${body}")
.setHeader("opName",constant("getAppStatus"))
.to("{{route.sampleURL}}")
.process(new GetApplicationStatusResponseProcessor()).end();
}
}
==================== 这里 : UserRefId和ConRefId用作请求验证器。
查询参数MainID是必需的,MainID2,MainID3,MainID4是可能包含空值的字段。
示例链接:
Link1 = http://localhost:8080/swagger/getAppStatus?MainID=12345&MainID2=&MainID3=&MainID4=
但是当它通过招摇的UI触发时,在CURL中显示:
仅当非必填字段生效时,问题才会持续存在。
是否存在任何参数,可以将空值插入为所需格式[Link1],就像错误链接[Link2]一样?