Search in sources :

Example 96 with JavaType

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project java-chassis by ServiceComb.

the class SFixed64ReadSchemas method create.

public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
    JavaType javaType = propertyDescriptor.getJavaType();
    if (long.class.equals(javaType.getRawClass())) {
        return new SFixed64PrimitiveSchema<>(protoField, propertyDescriptor);
    }
    if (Long.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
        return new SFixed64Schema<>(protoField, propertyDescriptor);
    }
    ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
    return null;
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType)

Example 97 with JavaType

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project java-chassis by ServiceComb.

the class SInt64ReadSchemas method create.

public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
    JavaType javaType = propertyDescriptor.getJavaType();
    if (long.class.equals(javaType.getRawClass())) {
        return new SInt64PrimitiveSchema<>(protoField, propertyDescriptor);
    }
    if (Long.class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
        return new SInt64Schema<>(protoField, propertyDescriptor);
    }
    ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
    return null;
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType)

Example 98 with JavaType

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project java-chassis by ServiceComb.

the class BytesReadSchemas method create.

public static <T> FieldSchema<T> create(Field protoField, PropertyDescriptor propertyDescriptor) {
    JavaType javaType = propertyDescriptor.getJavaType();
    if (byte[].class.equals(javaType.getRawClass()) || javaType.isJavaLangObject()) {
        return new BytesSchema<>(protoField, propertyDescriptor);
    }
    ProtoUtils.throwNotSupportMerge(protoField, propertyDescriptor.getJavaType());
    return null;
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType)

Example 99 with JavaType

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project java-chassis by ServiceComb.

the class TestModelResolverExt method setType.

@Test
public void setType() {
    JavaType type = TypeFactory.defaultInstance().constructCollectionType(List.class, String.class);
    resolver.setType(type, vendorExtensions);
    Assert.assertEquals("java.util.List<java.lang.String>", vendorExtensions.get(SwaggerConst.EXT_JAVA_CLASS));
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) Test(org.junit.Test)

Example 100 with JavaType

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.JavaType in project java-chassis by ServiceComb.

the class TestResponsesMeta method test.

@Test
public void test() {
    Swagger swagger = SwaggerGenerator.generate(ResponseMetaImpl.class);
    Operation operation = swagger.getPath("/add").getPost();
    ResponsesMeta meta = new ResponsesMeta();
    meta.init(swagger, operation);
    JavaType resp = meta.findResponseType(200);
    Assert.assertEquals(Integer.class, resp.getRawClass());
    resp = meta.findResponseType(201);
    Assert.assertEquals(Integer.class, resp.getRawClass());
    resp = meta.findResponseType(400);
    Assert.assertEquals(String.class, resp.getRawClass());
    resp = meta.findResponseType(401);
    Assert.assertEquals(Long.class, resp.getRawClass());
    resp = meta.findResponseType(500);
    // changed to Object for new version to keep user defined error data not lose and can be parsed.
    Assert.assertEquals(Object.class, resp.getRawClass());
}
Also used : JavaType(com.fasterxml.jackson.databind.JavaType) Swagger(io.swagger.models.Swagger) Operation(io.swagger.models.Operation) Test(org.junit.Test)

Aggregations

JavaType (com.fasterxml.jackson.databind.JavaType)322 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)36 Test (org.junit.Test)29 BeanDescription (com.fasterxml.jackson.databind.BeanDescription)25 IOException (java.io.IOException)25 BeanPropertyDefinition (com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition)22 ArrayList (java.util.ArrayList)21 TypeFactory (com.fasterxml.jackson.databind.type.TypeFactory)17 Property (io.swagger.models.properties.Property)16 List (java.util.List)16 Map (java.util.Map)14 ModelImpl (io.swagger.models.ModelImpl)13 StringProperty (io.swagger.models.properties.StringProperty)13 Annotation (java.lang.annotation.Annotation)12 Method (java.lang.reflect.Method)11 Type (java.lang.reflect.Type)11 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)10 BodyParameter (io.swagger.models.parameters.BodyParameter)10 MapProperty (io.swagger.models.properties.MapProperty)10 JsonDeserializer (com.fasterxml.jackson.databind.JsonDeserializer)9