Search in sources :

Example 1 with OasXML

use of io.apicurio.datamodels.openapi.models.OasXML in project apicurio-data-models by Apicurio.

the class Oas30Schema method createXML.

/**
 * @see io.apicurio.datamodels.openapi.models.OasSchema#createXML()
 */
@Override
public OasXML createXML() {
    OasXML rval = new Oas30XML();
    rval._ownerDocument = this.ownerDocument();
    rval._parent = this;
    return rval;
}
Also used : OasXML(io.apicurio.datamodels.openapi.models.OasXML)

Example 2 with OasXML

use of io.apicurio.datamodels.openapi.models.OasXML in project syndesis by syndesisio.

the class UnifiedXmlDataShapeSupport method determineArrayElementName.

public static String determineArrayElementName(final String propertyName, final OasSchema array) {
    final OasXML xml = array.xml;
    if (xml == null || xml.wrapped == null || Boolean.FALSE.equals(xml.wrapped)) {
        return null;
    }
    final String xmlName = xml.name;
    if (xmlName != null) {
        return xmlName;
    }
    return propertyName;
}
Also used : OasXML(io.apicurio.datamodels.openapi.models.OasXML)

Example 3 with OasXML

use of io.apicurio.datamodels.openapi.models.OasXML in project syndesis by syndesisio.

the class XmlSchemaHelper method isAttribute.

public static boolean isAttribute(final OasSchema property) {
    final OasXML xml = property.xml;
    if (xml == null) {
        return false;
    }
    final Boolean attribute = xml.attribute;
    return Boolean.TRUE.equals(attribute);
}
Also used : OasXML(io.apicurio.datamodels.openapi.models.OasXML)

Example 4 with OasXML

use of io.apicurio.datamodels.openapi.models.OasXML in project syndesis by syndesisio.

the class UnifiedXmlDataShapeSupport method determineArrayItemName.

public static String determineArrayItemName(final String propertyName, final OasSchema array) {
    final OasSchema items = (OasSchema) array.items;
    final OasXML itemXml = items.xml;
    if (itemXml != null && itemXml.name != null) {
        return itemXml.name;
    }
    final OasXML xml = array.xml;
    if (xml != null && xml.name != null) {
        return xml.name;
    }
    return propertyName;
}
Also used : OasSchema(io.apicurio.datamodels.openapi.models.OasSchema) OasXML(io.apicurio.datamodels.openapi.models.OasXML)

Example 5 with OasXML

use of io.apicurio.datamodels.openapi.models.OasXML in project syndesis by syndesisio.

the class UnifiedXmlDataShapeSupport method defineArrayElement.

public void defineArrayElement(final OasSchema property, final String propertyName, final Element parent, final T openApiDoc, final Map<String, SchemaPrefixAndElement> moreSchemas) {
    final Element sequence;
    final OasXML arrayXml = property.xml;
    if (arrayXml != null && Boolean.TRUE.equals(arrayXml.wrapped)) {
        final String arrayElementName = determineArrayElementName(propertyName, property);
        final Element arrayElement = XmlSchemaHelper.addElement(parent, ELEMENT);
        arrayElement.addAttribute(NAME, requireNonNull(arrayElementName, "missing array property name"));
        final Element arrayComplex = XmlSchemaHelper.addElement(arrayElement, COMPLEX_TYPE);
        sequence = XmlSchemaHelper.addElement(arrayComplex, SEQUENCE);
    } else {
        sequence = parent;
    }
    final OasSchema items = (OasSchema) property.items;
    final Element itemsElement;
    if (OasModelHelper.isReferenceType(items)) {
        itemsElement = defineComplexElement(items, sequence, openApiDoc, moreSchemas);
    } else {
        itemsElement = XmlSchemaHelper.addElement(sequence, ELEMENT);
        itemsElement.addAttribute(NAME, determineArrayItemName(propertyName, property));
        itemsElement.addAttribute(TYPE, XmlSchemaHelper.toXsdType(items.type));
    }
    if (property.maxItems == null) {
        itemsElement.addAttribute("maxOccurs", "unbounded");
    } else {
        itemsElement.addAttribute("maxOccurs", String.valueOf(property.maxItems));
    }
    if (property.minItems == null) {
        itemsElement.addAttribute("minOccurs", "0");
    } else {
        itemsElement.addAttribute("minOccurs", String.valueOf(property.minItems));
    }
}
Also used : OasSchema(io.apicurio.datamodels.openapi.models.OasSchema) Element(org.dom4j.Element) OasXML(io.apicurio.datamodels.openapi.models.OasXML)

Aggregations

OasXML (io.apicurio.datamodels.openapi.models.OasXML)6 OasSchema (io.apicurio.datamodels.openapi.models.OasSchema)2 Element (org.dom4j.Element)1