Improved support for XML wrapped items (#6150)

* Improved support for XML wrapped items

* XML @annotation whitespace fixed
This commit is contained in:
mobreza
2017-08-03 16:44:17 +08:00
committed by wing328
parent b433afebdd
commit b4e0854823
6 changed files with 90 additions and 11 deletions

View File

@@ -60,6 +60,7 @@ public class CodegenProperty implements Cloneable {
public String xmlPrefix;
public String xmlName;
public String xmlNamespace;
public boolean isXmlWrapped = false;
@Override
@@ -135,6 +136,7 @@ public class CodegenProperty implements Cloneable {
result = prime * result + ((xmlPrefix == null) ? 0 : xmlPrefix.hashCode());
result = prime * result + ((xmlName == null) ? 0 : xmlName.hashCode());
result = prime * result + ((xmlNamespace == null) ? 0 : xmlNamespace.hashCode());
result = prime * result + ((isXmlWrapped ? 13:31));
return result;
}
@@ -322,6 +324,9 @@ public class CodegenProperty implements Cloneable {
if (!Objects.equals(this.xmlNamespace, other.xmlNamespace)) {
return false;
}
if (!Objects.equals(this.isXmlWrapped, other.isXmlWrapped)) {
return false;
}
return true;
}

View File

@@ -1816,13 +1816,19 @@ public class DefaultCodegen {
property.isListContainer = true;
property.containerType = "array";
property.baseType = getSwaggerType(p);
if (p.getXml() != null) {
property.isXmlWrapped = p.getXml().getWrapped() == null ? false : p.getXml().getWrapped();
property.xmlPrefix= p.getXml().getPrefix();
property.xmlNamespace = p.getXml().getNamespace();
property.xmlName = p.getXml().getName();
}
// handle inner property
ArrayProperty ap = (ArrayProperty) p;
property.maxItems = ap.getMaxItems();
property.minItems = ap.getMinItems();
String itemName = (String) p.getVendorExtensions().get("x-item-name");
if (itemName == null) {
itemName = property.name;
itemName = property.name;
}
CodegenProperty cp = fromProperty(itemName, ap.getItems());
updatePropertyForArray(property, cp);