use of io.swagger.models.properties.ObjectProperty in project teiid by teiid.
the class SwaggerMetadataProcessor method walkProperties.
private void walkProperties(final Swagger swagger, Set<Property> parents, final Map<String, Property> properties, final String namePrefix, final String nisPrefix, final PropertyAction pa) {
if (properties == null) {
return;
}
final PropertyVisitor visitor = new PropertyVisitor() {
@Override
public void visit(String name, Property property) {
pa.execute(fqn(namePrefix, name), nis(nisPrefix, name, false), property, false);
}
@Override
public void visit(String name, ArrayProperty property) {
if (isSimple(property)) {
// the array type defined in the type of the property
pa.execute(fqn(namePrefix, name), nis(nisPrefix, name, false), property.getItems(), true);
} else {
// if Object or Ref, array does not matter as return is already a resultset.
Property items = property.getItems();
parents.add(property);
if (items instanceof ObjectProperty) {
String modelName = ((ObjectProperty) items).getName();
walkProperties(swagger, parents, ((ObjectProperty) items).getProperties(), fqn(fqn(namePrefix, name), modelName), nis(nis(nisPrefix, name, true), modelName, false), pa);
} else if (items instanceof RefProperty) {
String modelName = ((RefProperty) items).getSimpleRef();
Model model = swagger.getDefinitions().get(modelName);
walkProperties(swagger, parents, model.getProperties(), fqn(fqn(namePrefix, name), modelName), nis(nis(nisPrefix, name, true), modelName, false), pa);
} else {
walkProperties(swagger, parents, properties, fqn(namePrefix, name), nis(nisPrefix, name, true), pa);
}
parents.remove(property);
}
}
@Override
public void visit(String name, FileProperty property) {
// TODO:
}
@Override
public void visit(String name, MapProperty property) {
// TODO:
}
@Override
public void visit(String name, ObjectProperty property) {
parents.add(property);
walkProperties(swagger, parents, property.getProperties(), fqn(namePrefix, name), nis(nisPrefix, name, false), pa);
parents.remove(property);
}
@Override
public void visit(String name, RefProperty property) {
parents.add(property);
Model model = swagger.getDefinitions().get(property.getSimpleRef());
walkProperties(swagger, parents, model.getProperties(), fqn(namePrefix, name), nis(nisPrefix, name, false), pa);
parents.remove(property);
}
};
for (Entry<String, Property> p : properties.entrySet()) {
if (parents.contains(p.getValue())) {
// TODO: could be an error condition
continue;
}
visitor.accept(p.getKey(), p.getValue());
}
}
use of io.swagger.models.properties.ObjectProperty in project java-chassis by ServiceComb.
the class TestSwaggerUtils method isComplexProperty.
@Test
public void isComplexProperty() {
Property property = new RefProperty("ref");
Assert.assertTrue(SwaggerUtils.isComplexProperty(property));
property = new ObjectProperty();
Assert.assertTrue(SwaggerUtils.isComplexProperty(property));
property = new MapProperty();
Assert.assertTrue(SwaggerUtils.isComplexProperty(property));
property = new ArrayProperty(new ObjectProperty());
Assert.assertTrue(SwaggerUtils.isComplexProperty(property));
property = new ArrayProperty(new StringProperty());
Assert.assertFalse(SwaggerUtils.isComplexProperty(property));
property = new StringProperty();
Assert.assertFalse(SwaggerUtils.isComplexProperty(property));
}
use of io.swagger.models.properties.ObjectProperty in project carbon-apimgt by wso2.
the class WSDL11SOAPOperationExtractor method addAttributesToModel.
private void addAttributesToModel(ModelImpl model, NamedNodeMap namedNodeMap) {
if (namedNodeMap == null || namedNodeMap.getNamedItem(NAME_ATTRIBUTE) == null) {
return;
}
String name = namedNodeMap.getNamedItem(NAME_ATTRIBUTE).getNodeValue();
Map<String, Property> properties = new HashMap<>();
if (model.getProperties() == null || !model.getProperties().containsKey(ATTR_CONTENT_KEYWORD)) {
ObjectProperty objectProperty = new ObjectProperty();
objectProperty.setProperties(properties);
model.addProperty(ATTR_CONTENT_KEYWORD, objectProperty);
}
ObjectProperty objectProperty = (ObjectProperty) model.getProperties().get(ATTR_CONTENT_KEYWORD);
objectProperty.getProperties().put(name, new StringProperty());
}
use of io.swagger.models.properties.ObjectProperty in project swagger-parser by swagger-api.
the class SwaggerInventory method process.
public void process(Property property) {
this.properties.add(property);
if (property instanceof ArrayProperty) {
ArrayProperty p = (ArrayProperty) property;
Property ap = p.getItems();
this.process(ap);
} else if (property instanceof MapProperty) {
MapProperty p1 = (MapProperty) property;
} else if (property instanceof ObjectProperty) {
ObjectProperty p2 = (ObjectProperty) property;
if (p2.getProperties() != null) {
Iterator ap1 = p2.getProperties().keySet().iterator();
while (ap1.hasNext()) {
String name = (String) ap1.next();
Property ip = (Property) p2.getProperties().get(name);
this.process(ip);
}
}
}
}
Aggregations