use of io.swagger.models.properties.ArrayProperty in project incubator-servicecomb-java-chassis by apache.
the class AnnotationUtils method generateResponseProperty.
public static Property generateResponseProperty(Swagger swagger, ResponseConfigBase config) throws Error {
Class<?> responseClass = config.getResponseClass();
if (responseClass == null || ReflectionUtils.isVoid(responseClass)) {
return null;
}
if (!ClassUtils.isPrimitiveOrWrapper(responseClass)) {
Map<String, Model> newDefinitions = ModelConverters.getInstance().readAll(responseClass);
appendDefinition(swagger, newDefinitions);
}
Property property = ModelConverters.getInstance().readAsProperty(responseClass);
// 根据swagger定义这里是区分大小写的, 虽然不明白为何这样做,不过还是不要改标准了
switch(config.getResponseContainer()) {
case "List":
property = new ArrayProperty(property);
break;
case "Set":
property = new ArrayProperty(property);
((ArrayProperty) property).setUniqueItems(true);
break;
case "Map":
property = new MapProperty(property);
break;
case "":
// 不必处理
break;
default:
throw new Error("not support responseContainer " + config.getResponseContainer());
}
return property;
}
use of io.swagger.models.properties.ArrayProperty in project incubator-servicecomb-java-chassis by apache.
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));
}
Aggregations