use of io.swagger.models.ModelImpl in project java-chassis by ServiceComb.
the class ModelImplConverter method doConvert.
@Override
public JavaType doConvert(ClassLoader classLoader, String packageName, Swagger swagger, Object model) {
ModelImpl modelImpl = (ModelImpl) model;
JavaType javaType = ConverterMgr.findJavaType(modelImpl.getType(), modelImpl.getFormat());
if (javaType != null) {
return javaType;
}
if (modelImpl.getReference() != null) {
return ConverterMgr.findByRef(classLoader, packageName, swagger, modelImpl.getReference());
}
// 根据name、property动态生成class
if (packageName == null) {
throw new Error("packageName should not be null");
}
String clsName = packageName + "." + modelImpl.getName();
Class<?> cls = ClassUtils.getOrCreateClass(classLoader, packageName, swagger, modelImpl, clsName);
return TypeFactory.defaultInstance().constructType(cls);
}
use of io.swagger.models.ModelImpl in project carbon-apimgt by wso2.
the class APIDefinitionFromSwagger20 method getDefaultBodyParameter.
private BodyParameter getDefaultBodyParameter() {
BodyParameter bodyParameter = new BodyParameter();
bodyParameter.setName("Payload");
bodyParameter.setDescription("Request Body");
bodyParameter.setRequired(false);
Model model = new ModelImpl();
Map<String, Property> properties = new HashMap<>();
Property property = new StringProperty();
properties.put("payload", property);
model.setProperties(properties);
bodyParameter.setSchema(model);
return bodyParameter;
}
use of io.swagger.models.ModelImpl in project minijax by minijax.
the class ScannerTest method scanBeanParamResource.
@Test
public void scanBeanParamResource() {
final Swagger swagger = getSwagger(ResourceWithBeanParams.class);
final List<Parameter> params = getParameters(swagger, "/bean/{id}");
final HeaderParameter headerParam1 = (HeaderParameter) params.get(0);
assertEquals(1, headerParam1.getDefaultValue());
assertEquals("test order annotation 1", headerParam1.getName());
final HeaderParameter headerParam2 = (HeaderParameter) params.get(1);
assertEquals(2, headerParam2.getDefaultValue());
assertEquals("test order annotation 2", headerParam2.getName());
final QueryParameter priority1 = (QueryParameter) params.get(2);
assertNull(priority1.getDefaultValue());
assertEquals("test priority 1", priority1.getName());
final QueryParameter priority2 = (QueryParameter) params.get(3);
assertEquals(4, priority2.getDefaultValue());
assertEquals("test priority 2", priority2.getName());
final ModelImpl bodyParam1 = (ModelImpl) ((BodyParameter) params.get(4)).getSchema();
assertEquals("bodyParam", bodyParam1.getDefaultValue());
}
use of io.swagger.models.ModelImpl in project incubator-servicecomb-java-chassis by apache.
the class PendingBodyParameter method toRefModel.
// swagger中的body只能是ref,不能是简单类型
private RefModel toRefModel(String modelType) {
if (RefProperty.class.isInstance(property)) {
return (RefModel) PropertyBuilder.toModel(property);
}
ModelImpl modelImpl = new ModelImpl();
modelImpl.setType("object");
modelImpl.setName(name);
modelImpl.addProperty(name, property);
operationGenerator.getSwagger().addDefinition(modelType, modelImpl);
RefModel refModel = new RefModel();
refModel.setReference("#/definitions/" + modelType);
return refModel;
}
use of io.swagger.models.ModelImpl in project incubator-servicecomb-java-chassis by apache.
the class ModelImplConverter method doConvert.
@Override
public JavaType doConvert(ClassLoader classLoader, String packageName, Swagger swagger, Object model) {
ModelImpl modelImpl = (ModelImpl) model;
JavaType javaType = ConverterMgr.findJavaType(modelImpl.getType(), modelImpl.getFormat());
if (javaType != null) {
return javaType;
}
if (modelImpl.getReference() != null) {
return ConverterMgr.findByRef(classLoader, packageName, swagger, modelImpl.getReference());
}
if (modelImpl.getAdditionalProperties() != null) {
return MapPropertyConverter.findJavaType(classLoader, packageName, swagger, modelImpl.getAdditionalProperties());
}
if (ObjectProperty.TYPE.equals(modelImpl.getType()) && modelImpl.getProperties() == null && modelImpl.getName() == null) {
return TypeFactory.defaultInstance().constructType(Object.class);
}
return getOrCreateType(classLoader, packageName, swagger, modelImpl);
}
Aggregations