Spring boot Camel REST-DSL多查询参数传递时带有null值,给出错误
我已经在spring boot项目中创建了Camel Rest DSL。现在在swagger实现时,当我传递带有必填字段和非必填字段的多个查询参数时,它没有捕获非必填字段的空值 我的is示例代码如下所示: ================ 公共类路由器扩展RouteBuilder{Spring boot Camel REST-DSL多查询参数传递时带有null值,给出错误,spring-boot,apache-camel,swagger,dsl,Spring Boot,Apache Camel,Swagger,Dsl,我已经在spring boot项目中创建了Camel Rest DSL。现在在swagger实现时,当我传递带有必填字段和非必填字段的多个查询参数时,它没有捕获非必填字段的空值 我的is示例代码如下所示: ================ 公共类路由器扩展RouteBuilder{ @Override public void configure() throws Exception,PredicateValidationException { JsonDataFormat jso
@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是可能包含空值的字段
示例链接:
链接1=
但当它通过swagger UI触发时,在CURL中显示:
链接2=
问题仅在非必填字段生效时持续存在
是否有任何参数允许以所需格式[Link1]插入空值,而不是像错误链接[Link2]?对于rest dsl中的查询参数,您不能使用
{xxx}
样式(仅用于内容路径)执行此操作。所以只要删除?
标记之后的所有内容,它就会工作。谢谢你,克劳斯·易卜生,我只尝试从一些查询参数中删除“{}”,但它们不起作用。现在,根据您的建议,我已经删除了“?”之后的所有“{}”,它正在工作:)当前链接看起来像:其中12345是“MainID”,这是必需的字段。您不能对具有{xxx}
样式的剩余dsl中的查询参数执行此操作,这仅适用于内容路径。所以只要删除?
标记之后的所有内容,它就会工作。谢谢你,克劳斯·易卜生,我只尝试从一些查询参数中删除“{}”,但它们不起作用。现在根据您的建议,我已经删除了“?”之后的所有“{}”,并且它正在工作:)当前链接看起来像:其中12345是“MainID”,这是必填字段。