Hello everybody!
I'm trying to convert an xml schema (xsd) in JSON schema; I have a problem transforming the following xsd element:
<xs:complexType name="RuleType">
<xs:sequence>
<xs:element name="event" type="EventType" minOccurs="1" maxOccurs="1"/>
<xs:element name="condition" type="ConditionType" minOccurs="0"/>
<xs:choice minOccurs="1" maxOccurs="1">
<xs:element name="action" type="ActionType"/>
<xs:element name="rule" type="RuleType"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
This is the correspondent json schema definition
"RuleType" : {
"type" : "object",
"properties" : {
"event" : { "$ref" : "#/definitions/EventType" },
"condition" : { "$ref" : "#/definitions/ConditionType" },
"actionOrRule" : {
"type" : "object",
"oneOf": [
{ "$ref": "#/definitions/ActionType" },
{ "$ref": "#" }
]
}
}
}
"ActionType" : {
"type" : "object",
"properties" : {
"create" : {
"type" : "array",
"items" : { "$ref" : "#/definitions/CreateActionType" }
},
"read" : {
"type" : "array",
"items" : { "$ref" : "#/definitions/ReadActionType" }
}
}
}
This is the code generated through jsonschema2pojo:
...
public class Rule {
@JsonProperty("event")
private Event event;
@JsonProperty("condition")
private Condition condition;
@JsonProperty("actionOrRule")
private ActionOrRule actionOrRule;
//getter and setter
}
The rule class is ok, but the ActionOrRule class is not well generated:
public class ActionOrRule {
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
@Override
public int hashCode() {
return HashCodeBuilder.reflectionHashCode(this);
}
@Override
public boolean equals(Object other) {
return EqualsBuilder.reflectionEquals(this, other);
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperties(String name, Object value) {
this.additionalProperties.put(name, value);
}
}
There are no references to action or tule class, it seems a problem with the oneOf key word, does anyone knows if jsonschema2pojo support the oneOf construct?
If can help I can attach the draft of my json schema.
Kind regards.
Marco