I am trying to create a person rest service.And am trying to create xml schema using JAXB and JSon Schema Using Jackson.
So Here is my Model classes to create the respective XML as well as JSon Payload.
package www.tempuri.person.model; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import javax.xml.bind.annotation.XmlRootElement; import com.fasterxml.jackson.annotation.JsonRootName; @ApiModel(value="GetPerson Message",description = "Personal Input Request") @XmlRootElement(name="getPerson") @JsonRootName(value = "getPerson") public class GetPersonWrapper { @ApiModelProperty(value = "GetPerson", required = true) private GetPerson getPerson; public GetPerson getGetPerson() { return getPerson; } public void setGetPerson(GetPerson getPerson) { this.getPerson = getPerson; } } package www.tempuri.person.model; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; @ApiModel(description = "Represents Persons") public class GetPerson { @ApiModelProperty(value = "Application Area of GetPerson", required = true) private ApplicationArea applicationArea; @ApiModelProperty(value = "Data Area of GetPerson", required = true) private DataAreaGet dataArea; /** * @return the dataArea */ public DataAreaGet getDataArea() { return dataArea; } /** * @param dataArea the dataArea to set */ public void setDataArea(DataAreaGet dataArea) { this.dataArea = dataArea; } public ApplicationArea getApplicationArea() { return applicationArea; } public void setApplicationArea(ApplicationArea applicationArea) { this.applicationArea = applicationArea; } } With the above model classes, the json schema is coming as intended. But in case of xml i am not able to get what i want to: Below is the schema that it generated in xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <getPerson> <getPerson> <applicationArea/> <dataArea> <description>string</description> <id>0</id> <name>string</name> </dataArea> </getPerson> </getPerson> As you can see i am getting two getPerson Node. How can i remove one of the getPerson node.
I am using apache camel swagger component to create the rest service.
Looking forward to your solutions. Thanks in advance.
No comments:
Post a Comment