Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate classes in package com.fasterxml.jackson.databind.jsonschema #3745

Merged
merged 3 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ public void serialize(Node value, JsonGenerator g, SerializerProvider provider)
}
}

/**
* @deprecated Since 2.15
*/
@Deprecated
cowtowncoder marked this conversation as resolved.
Show resolved Hide resolved
@Override
public JsonNode getSchema(SerializerProvider provider, java.lang.reflect.Type typeHint) {
// Well... it is serialized as String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@
*
* @author Ryan Heaton
* @author Tatu Saloranta
* @deprecated Since 2.15, we recommend use of external
* <a href="https://github.com/FasterXML/jackson-module-jsonSchema">JSON Schema generator module</a>
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotation
@Deprecated
public @interface JsonSerializableSchema
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@

/**
* Marker interface for schema-aware serializers.
*
* @deprecated Since 2.15, we recommend use of external
* <a href="https://github.com/FasterXML/jackson-module-jsonSchema">JSON Schema generator module</a>
*/
@Deprecated
public interface SchemaAware
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.fasterxml.jackson.databind.introspect.Annotated;
import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import com.fasterxml.jackson.databind.jsonschema.SchemaAware;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.ser.impl.WritableObjectId;
Expand Down Expand Up @@ -583,8 +582,9 @@ public com.fasterxml.jackson.databind.jsonschema.JsonSchema generateJsonSchema(C
* type information it needs is accessible via "untyped" serializer)
*/
JsonSerializer<Object> ser = findValueSerializer(type, null);
JsonNode schemaNode = (ser instanceof SchemaAware) ?
((SchemaAware) ser).getSchema(this, null) : com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode();
JsonNode schemaNode = (ser instanceof com.fasterxml.jackson.databind.jsonschema.SchemaAware)
? ((com.fasterxml.jackson.databind.jsonschema.SchemaAware) ser).getSchema(this, null)
: com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode();
if (!(schemaNode instanceof ObjectNode)) {
throw new IllegalArgumentException("Class " + type.getName()
+" would not be serialized as a JSON object and therefore has no schema");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ private void serializeContentsSlow(String[] value, JsonGenerator gen, Serializer
}
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
return createSchemaNode("array", true).set("items", createSchemaNode("string"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import com.fasterxml.jackson.databind.jsonschema.SchemaAware;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.ser.ContainerSerializer;
Expand Down Expand Up @@ -271,16 +270,20 @@ public void serializeWithType(T value, JsonGenerator g, SerializerProvider provi
protected abstract void serializeContents(T value, JsonGenerator gen, SerializerProvider provider)
throws IOException;

@SuppressWarnings("deprecation")
/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
throws JsonMappingException
{
ObjectNode o = createSchemaNode("array", true);
if (_elementSerializer != null) {
JsonNode schemaNode = null;
if (_elementSerializer instanceof SchemaAware) {
schemaNode = ((SchemaAware) _elementSerializer).getSchema(provider, null);
if (_elementSerializer instanceof com.fasterxml.jackson.databind.jsonschema.SchemaAware) {
schemaNode = ((com.fasterxml.jackson.databind.jsonschema.SchemaAware) _elementSerializer)
.getSchema(provider, null);
}
if (schemaNode == null) {
schemaNode = com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor;
import com.fasterxml.jackson.databind.jsonschema.JsonSerializableSchema;
import com.fasterxml.jackson.databind.jsonschema.SchemaAware;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.databind.ser.*;
Expand All @@ -40,7 +38,7 @@
public abstract class BeanSerializerBase
extends StdSerializer<Object>
implements ContextualSerializer, ResolvableSerializer,
JsonFormatVisitable, SchemaAware
JsonFormatVisitable
{
protected final static PropertyName NAME_FOR_OBJECT_REF = new PropertyName("#object-ref");

Expand Down Expand Up @@ -849,7 +847,8 @@ public JsonNode getSchema(SerializerProvider provider, Type typeHint)
ObjectNode o = createSchemaNode("object", true);
// [JACKSON-813]: Add optional JSON Schema id attribute, if found
// NOTE: not optimal, does NOT go through AnnotationIntrospector etc:
JsonSerializableSchema ann = _handledType.getAnnotation(JsonSerializableSchema.class);
com.fasterxml.jackson.databind.jsonschema.JsonSerializableSchema ann =
_handledType.getAnnotation(com.fasterxml.jackson.databind.jsonschema.JsonSerializableSchema.class);
if (ann != null) {
String id = ann.id();
if (id != null && !id.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public final void serializeWithType(Object value, JsonGenerator g, SerializerPro
g.writeBoolean(Boolean.TRUE.equals(value));
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
return createSchemaNode("boolean", !_forPrimitive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ public void serializeWithType(byte[] value, JsonGenerator g, SerializerProvider
*/
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ public void serialize(Class<?> value, JsonGenerator g, SerializerProvider provid
g.writeString(value.getName());
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ public boolean isEmpty(SerializerProvider serializers, T value) {

protected abstract long _timestamp(T value);

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider serializers, Type typeHint) {
//todo: (ryan) add a format for the date in the schema?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ public final void serialize(Enum<?> en, JsonGenerator gen, SerializerProvider se
/**********************************************************
*/

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public void serialize(File value, JsonGenerator g, SerializerProvider provider)
g.writeString(value.getAbsolutePath());
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
return createSchemaNode("string", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor;
import com.fasterxml.jackson.databind.jsonschema.SchemaAware;
import com.fasterxml.jackson.databind.jsontype.TypeIdResolver;
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
import com.fasterxml.jackson.databind.ser.BeanSerializer;
Expand All @@ -41,7 +40,7 @@
@JacksonStdImpl
public class JsonValueSerializer
extends StdSerializer<Object>
implements ContextualSerializer, JsonFormatVisitable, SchemaAware
implements ContextualSerializer, JsonFormatVisitable
{
/**
* @since 2.9
Expand Down Expand Up @@ -302,13 +301,17 @@ public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider
/**********************************************************
*/

@SuppressWarnings("deprecation")
/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider ctxt, Type typeHint)
throws JsonMappingException
{
if (_valueSerializer instanceof SchemaAware) {
return ((SchemaAware)_valueSerializer).getSchema(ctxt, null);
if (_valueSerializer instanceof com.fasterxml.jackson.databind.jsonschema.SchemaAware) {
return ((com.fasterxml.jackson.databind.jsonschema.SchemaAware) _valueSerializer)
.getSchema(ctxt, null);
}
return com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,10 @@ public void serializeFilteredAnyProperties(SerializerProvider provider, JsonGene
/**********************************************************
*/

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ public void serializeWithType(Object value, JsonGenerator gen, SerializerProvide
{
gen.writeNull();
}


/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException {
return createSchemaNode("null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public void serialize(Number value, JsonGenerator g, SerializerProvider provider
}
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
return createSchemaNode(_isInt ? "integer" : "number", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ protected Base(Class<?> cls, JsonParser.NumberType numberType,
|| (numberType == JsonParser.NumberType.BIG_INTEGER);
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
return createSchemaNode(_schemaType, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public void serializeWithType(T value, JsonGenerator g, SerializerProvider provi
serialize(value, g, provider);
typeSer.writeTypeSuffix(g, typeIdDef);
}


/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public void serialize(java.sql.Time value, JsonGenerator g, SerializerProvider p
g.writeString(value.toString());
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
return createSchemaNode("string", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ public boolean isEmpty(SerializerProvider provider, T value) {
return (value == null) || (value.isEmpty());
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
return createSchemaNode("array", true).set("items", contentSchema());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ public void serializeContents(boolean[] value, JsonGenerator g, SerializerProvid
}
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
{
Expand Down Expand Up @@ -232,6 +236,10 @@ public void serializeContents(short[] value, JsonGenerator g, SerializerProvider
}
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
{
Expand Down Expand Up @@ -307,6 +315,10 @@ private final void _writeArrayContents(JsonGenerator g, char[] value)
}
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
{
Expand Down Expand Up @@ -397,6 +409,10 @@ public void serializeContents(int[] value, JsonGenerator g, SerializerProvider p
}
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
return createSchemaNode("array", true).set("items", createSchemaNode("integer"));
Expand Down Expand Up @@ -469,6 +485,10 @@ public void serializeContents(long[] value, JsonGenerator g, SerializerProvider
}
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
{
Expand Down Expand Up @@ -547,6 +567,10 @@ public void serializeContents(float[] value, JsonGenerator g, SerializerProvider
}
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
return createSchemaNode("array", true).set("items", createSchemaNode("number"));
Expand Down Expand Up @@ -631,6 +655,10 @@ public void serializeContents(double[] value, JsonGenerator g, SerializerProvide
}
}

/**
* @deprecated Since 2.15
*/
@Deprecated
@Override
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
return createSchemaNode("array", true).set("items", createSchemaNode("number"));
Expand Down
Loading