我正在尝试使用apache camel swagger组件创建休息服务。
现在我有这个骆驼语境:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<!-- a bean for user services -->
<bean id="personService" class="www.tempuri.person.PersonService"/>
<camelContext id="myCamel" xmlns="http://camel.apache.org/schema/spring">
<restConfiguration component="servlet" bindingMode="auto" contextPath="myService/rest" port="8080">
<dataFormatProperty key="prettyPrint" value="true"/>
</restConfiguration>
<!-- defines the rest services using the context-path /Equipment -->
<rest path="/getPerson/persons" consumes="application/json,application/xml" produces="application/json,application/xml">
<description>Person rest service</description>
<post uri="/search" type="www.tempuri.person.model.GetPerson"
outType="www.tempuri.person.model.GetPerson">
<description>Get Person(s)</description>
<param name="body" type="body" description="Get Person(s)" required="true"/>
<responseMessage code="400" message="Bad Request" />
<responseMessage code="200" message="Person Data" />
<responseMessage code="401" message="Unauthorized" />
<to uri="bean:personService?method=getPersons"/>
</post>
</rest>
</camelContext>
</beans>
以下是我的模特类GetPerson:
package www.tempuri.person.model;
import javax.xml.bind.annotation.XmlRootElement;
import com.fasterxml.jackson.annotation.JsonRootName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
@ApiModel(description = "Represents Persons")
@XmlRootElement(name="getPerson")
@JsonRootName(value = "getPerson")
public class GetPerson {
@ApiModelProperty(value = "Application Area of GetPerson", required = true)
private ApplicationArea applicationArea;
@ApiModelProperty(value = "Data Area of GetPerson", required = true)
private DataArea dataArea;
/**
* @return the dataArea
*/
public DataArea getDataArea() {
return dataArea;
}
/**
* @param dataArea the dataArea to set
*/
public void setDataArea(DataArea dataArea) {
this.dataArea = dataArea;
}
public ApplicationArea getApplicationArea() {
return applicationArea;
}
public void setApplicationArea(ApplicationArea applicationArea) {
this.applicationArea = applicationArea;
}
}
现在,在应用程序xml的情况下,它运行良好,请求结构的根元素为getPerson,但在JSON请求的情况下,它不会显示根元素getPerson。我知道有一些名为 WRAP_ROOT_VALUE 的东西可用于在json的情况下启用根名称。但问题是我不知道如何使用camel-config.xml。
如何通过camel-config.xml设置WRAP_ROOT_VALUE或者还有其他方法。提前谢谢..