use of io.swagger.models.ArrayModel in project syndesis by syndesisio.
the class UnifiedXmlDataShapeGenerator method createRequestBodySchema.
private static Element createRequestBodySchema(final Swagger swagger, final Operation operation, final Map<String, SchemaPrefixAndElement> moreSchemas) {
final Optional<BodyParameter> bodyParameter = findBodyParameter(operation);
if (!bodyParameter.isPresent()) {
return null;
}
final BodyParameter body = bodyParameter.get();
final Model bodySchema = body.getSchema();
final ModelImpl bodySchemaToUse;
if (bodySchema instanceof RefModel) {
bodySchemaToUse = dereference((RefModel) bodySchema, swagger);
} else if (bodySchema instanceof ArrayModel) {
final Property items = ((ArrayModel) bodySchema).getItems();
if (items instanceof RefProperty) {
bodySchemaToUse = dereference((RefProperty) items, swagger);
} else {
bodySchemaToUse = new ModelImpl();
final String name = nameOrDefault(items, "array");
bodySchemaToUse.name(name);
bodySchemaToUse.addProperty(name, items);
}
} else {
bodySchemaToUse = (ModelImpl) bodySchema;
}
final String targetNamespace = xmlTargetNamespaceOrNull(bodySchemaToUse);
final Element schema = newXmlSchema(targetNamespace);
final Element bodyElement = addElement(schema, "element");
bodyElement.addAttribute("name", nameOf(bodySchemaToUse));
final Element complexBody = addElement(bodyElement, "complexType");
final Element bodySequence = addElement(complexBody, "sequence");
defineElementPropertiesOf(bodySequence, bodySchemaToUse, swagger, moreSchemas);
defineAttributePropertiesOf(complexBody, bodySchemaToUse);
return schema;
}
use of io.swagger.models.ArrayModel in project java-chassis by ServiceComb.
the class TestApiOperation method testSet.
private void testSet(Path path) {
Operation operation = path.getPost();
Model result200 = operation.getResponses().get("200").getResponseSchema();
Assert.assertEquals(ArrayModel.class, result200.getClass());
Assert.assertEquals(true, ((ArrayModel) result200).getUniqueItems());
}
Aggregations