use of io.swagger.models.ModelImpl in project carbon-apimgt by wso2.
the class WSDLSOAPOperationExtractorImplTestCase method testGetSwaggerModelElementForWSDLOperationElement.
@Test
public void testGetSwaggerModelElementForWSDLOperationElement() throws Exception {
List<ModelImpl> inputParameterModel = operations.iterator().next().getInputParameterModel();
Assert.assertEquals(1, operations.iterator().next().getOutputParameterModel().size());
for (ModelImpl model : inputParameterModel) {
Assert.assertTrue("CheckPhoneNumbers".equals(model.getName()) || "CheckPhoneNumber".equals(model.getName()));
}
}
use of io.swagger.models.ModelImpl in project incubator-servicecomb-java-chassis by apache.
the class TestApiOperation method testMap.
private void testMap(Path path) {
Operation operation = path.getPost();
Model result200 = operation.getResponses().get("200").getResponseSchema();
Assert.assertEquals(ModelImpl.class, result200.getClass());
Assert.assertTrue(((ModelImpl) result200).getAdditionalProperties() != null);
}
use of io.swagger.models.ModelImpl in project incubator-servicecomb-java-chassis by apache.
the class TestApiOperation method testPrimitive.
private void testPrimitive(Path path) {
Operation operation = path.getPost();
Assert.assertEquals(2, operation.getResponses().size());
ModelImpl result200 = (ModelImpl) operation.getResponses().get("200").getResponseSchema();
Assert.assertEquals("integer", result200.getType());
Assert.assertEquals("int32", result200.getFormat());
ModelImpl result202 = (ModelImpl) operation.getResponses().get("202").getResponseSchema();
Assert.assertEquals("string", result202.getType());
Assert.assertEquals(null, result202.getFormat());
}
use of io.swagger.models.ModelImpl in project incubator-servicecomb-java-chassis by apache.
the class AbstractOperationGenerator method fillBodyParameter.
protected void fillBodyParameter(Swagger swagger, Parameter parameter, Type type, List<Annotation> annotations) {
// so strange, for bodyParameter, swagger return a new instance
// that will cause lost some information
// so we must merge them
BodyParameter newBodyParameter = (BodyParameter) io.swagger.util.ParameterProcessor.applyAnnotations(swagger, parameter, type, annotations);
// swagger missed enum data, fix it
ModelImpl model = SwaggerUtils.getModelImpl(swagger, newBodyParameter);
if (model != null) {
Property property = ModelConverters.getInstance().readAsProperty(type);
if (property instanceof StringProperty) {
model.setEnum(((StringProperty) property).getEnum());
}
}
// swagger 2.0 do not support NotBlank and NotEmpty annotations, fix it
if (((JavaType) type).getBindings().getTypeParameters().isEmpty()) {
convertAnnotationProperty(((JavaType) type).getRawClass());
} else {
((JavaType) type).getBindings().getTypeParameters().stream().forEach(javaType -> convertAnnotationProperty(javaType.getRawClass()));
}
mergeBodyParameter((BodyParameter) parameter, newBodyParameter);
}
use of io.swagger.models.ModelImpl in project incubator-servicecomb-java-chassis by apache.
the class ModelResolverExt method resolve.
@Override
public Model resolve(JavaType type, ModelConverterContext context, Iterator<ModelConverter> next) {
// property is not a model
if (propertyCreatorMap.containsKey(type.getRawClass())) {
return null;
}
Model model = super.resolve(type, context, next);
if (model == null) {
return null;
}
checkType(type);
// 只有声明model的地方才需要标注类型
if (model instanceof ModelImpl && !StringUtils.isEmpty(((ModelImpl) model).getName())) {
setType(type, model.getVendorExtensions());
}
return model;
}
Aggregations