use of io.apicurio.datamodels.openapi.v2.models.Oas20Schema.Oas20PropertySchema in project apicurio-data-models by Apicurio.
the class Oas20to30TransformationVisitor method visitPropertySchema.
/**
* @see io.apicurio.datamodels.openapi.visitors.IOasVisitor#visitPropertySchema(io.apicurio.datamodels.core.models.common.IPropertySchema)
*/
@Override
public void visitPropertySchema(IPropertySchema node) {
Oas20PropertySchema ps20 = (Oas20PropertySchema) node;
Oas30Schema parent30 = (Oas30Schema) this.lookup(ps20.parent());
Oas30PropertySchema property30 = (Oas30PropertySchema) parent30.createPropertySchema(ps20.getPropertyName());
parent30.addProperty(ps20.getPropertyName(), property30);
this.toSchema(ps20, property30, true);
this.mapNode(ps20, property30);
}
use of io.apicurio.datamodels.openapi.v2.models.Oas20Schema.Oas20PropertySchema in project apicurio-data-models by Apicurio.
the class IoTestRunner method cloneNode.
static Node cloneNode(Node node) {
Constructor<? extends Node> constructor;
Node clonedNode = null;
try {
if (node instanceof INamed) {
constructor = node.getClass().getConstructor(String.class);
clonedNode = constructor.newInstance(((INamed) node).getName());
} else if (node instanceof OasPathItem) {
constructor = node.getClass().getConstructor(String.class);
clonedNode = constructor.newInstance(((OasPathItem) node).getPath());
} else if (node instanceof Operation) {
constructor = node.getClass().getConstructor(String.class);
clonedNode = constructor.newInstance(((Operation) node).getType());
} else if (node instanceof Oas20PropertySchema) {
constructor = node.getClass().getConstructor(String.class);
clonedNode = constructor.newInstance(((Oas20PropertySchema) node).getPropertyName());
} else if (node instanceof Oas30PropertySchema) {
constructor = node.getClass().getConstructor(String.class);
clonedNode = constructor.newInstance(((Oas30PropertySchema) node).getPropertyName());
} else if (node instanceof ServerVariable) {
constructor = node.getClass().getConstructor(String.class);
clonedNode = constructor.newInstance(((ServerVariable) node).getName());
} else {
constructor = node.getClass().getConstructor();
clonedNode = constructor.newInstance();
}
} catch (SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
System.err.println("Skipping partial I/O for: " + node.getClass().getSimpleName());
}
if (clonedNode != null) {
clonedNode._parent = node._parent;
clonedNode._ownerDocument = node.ownerDocument();
if (clonedNode instanceof Document) {
clonedNode._ownerDocument = (Document) clonedNode;
}
}
return clonedNode;
}
Aggregations