Search in sources :

Example 11 with JsonTypeInfo

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonTypeInfo in project jsonschema2pojo by joelittlejohn.

the class IncludeTypeInfoIT method disabledWithSchemaProperty.

@Test
public void disabledWithSchemaProperty() throws ClassNotFoundException {
    ClassLoader classLoader = schemaRule.generateAndCompile("/schema/typeInfo/typeInfoWithSchemaProperty.json", "com.example", config("includeTypeInfo", false));
    Class<?> classWithTypeInfo = classLoader.loadClass("com.example.TypeInfoWithSchemaProperty");
    assertNotNull(classWithTypeInfo.getAnnotation(JsonTypeInfo.class));
    JsonTypeInfo jsonTypeInfo = classWithTypeInfo.getAnnotation(JsonTypeInfo.class);
    assertThat(jsonTypeInfo.use(), is(JsonTypeInfo.Id.CLASS));
    assertThat(jsonTypeInfo.include(), is(JsonTypeInfo.As.PROPERTY));
    assertThat(jsonTypeInfo.property(), is("@clazz"));
}
Also used : JsonTypeInfo(com.fasterxml.jackson.annotation.JsonTypeInfo) Test(org.junit.Test)

Example 12 with JsonTypeInfo

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.annotation.JsonTypeInfo in project jsonschema2pojo by joelittlejohn.

the class IncludeTypeInfoIT method enabledWithSchemaProperty.

@Test
public void enabledWithSchemaProperty() throws ClassNotFoundException {
    ClassLoader classLoader = schemaRule.generateAndCompile("/schema/typeInfo/typeInfoWithSchemaProperty.json", "com.example", config("includeTypeInfo", true));
    Class<?> classWithTypeInfo = classLoader.loadClass("com.example.TypeInfoWithSchemaProperty");
    assertNotNull(classWithTypeInfo.getAnnotation(JsonTypeInfo.class));
    JsonTypeInfo jsonTypeInfo = classWithTypeInfo.getAnnotation(JsonTypeInfo.class);
    assertThat(jsonTypeInfo.use(), is(JsonTypeInfo.Id.CLASS));
    assertThat(jsonTypeInfo.include(), is(JsonTypeInfo.As.PROPERTY));
    assertThat(jsonTypeInfo.property(), is("@clazz"));
}
Also used : JsonTypeInfo(com.fasterxml.jackson.annotation.JsonTypeInfo) Test(org.junit.Test)

Aggregations

JsonTypeInfo (com.fasterxml.jackson.annotation.JsonTypeInfo)12 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 JsonIgnoreProperties (com.fasterxml.jackson.annotation.JsonIgnoreProperties)2 JsonProperty (com.fasterxml.jackson.annotation.JsonProperty)2 JsonSubTypes (com.fasterxml.jackson.annotation.JsonSubTypes)2 JsonUnwrapped (com.fasterxml.jackson.annotation.JsonUnwrapped)2 BeanDescription (com.fasterxml.jackson.databind.BeanDescription)2 JavaType (com.fasterxml.jackson.databind.JavaType)2 BeanPropertyDefinition (com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition)2 ApiModel (io.swagger.annotations.ApiModel)2 ApiModelProperty (io.swagger.annotations.ApiModelProperty)2 ModelImpl (io.swagger.models.ModelImpl)2 ArraySchema (io.swagger.v3.oas.models.media.ArraySchema)2 ComposedSchema (io.swagger.v3.oas.models.media.ComposedSchema)2 IntegerSchema (io.swagger.v3.oas.models.media.IntegerSchema)2 MapSchema (io.swagger.v3.oas.models.media.MapSchema)2 NumberSchema (io.swagger.v3.oas.models.media.NumberSchema)2 ObjectSchema (io.swagger.v3.oas.models.media.ObjectSchema)2 Schema (io.swagger.v3.oas.models.media.Schema)2