diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/DOMSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/DOMSerializer.java index 0b96dbc5a4..343eb0ebc5 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/DOMSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/DOMSerializer.java @@ -51,6 +51,10 @@ public void serialize(Node value, JsonGenerator g, SerializerProvider provider) } } + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, java.lang.reflect.Type typeHint) { // Well... it is serialized as String diff --git a/src/main/java/com/fasterxml/jackson/databind/jsonschema/JsonSerializableSchema.java b/src/main/java/com/fasterxml/jackson/databind/jsonschema/JsonSerializableSchema.java index b34ce6d355..3a9f03db99 100644 --- a/src/main/java/com/fasterxml/jackson/databind/jsonschema/JsonSerializableSchema.java +++ b/src/main/java/com/fasterxml/jackson/databind/jsonschema/JsonSerializableSchema.java @@ -17,10 +17,13 @@ * * @author Ryan Heaton * @author Tatu Saloranta + * @deprecated Since 2.15, we recommend use of external + * JSON Schema generator module */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) @JacksonAnnotation +@Deprecated public @interface JsonSerializableSchema { /** diff --git a/src/main/java/com/fasterxml/jackson/databind/jsonschema/SchemaAware.java b/src/main/java/com/fasterxml/jackson/databind/jsonschema/SchemaAware.java index f3505cd37d..8d7036fb8a 100644 --- a/src/main/java/com/fasterxml/jackson/databind/jsonschema/SchemaAware.java +++ b/src/main/java/com/fasterxml/jackson/databind/jsonschema/SchemaAware.java @@ -8,7 +8,11 @@ /** * Marker interface for schema-aware serializers. + * + * @deprecated Since 2.15, we recommend use of external + * JSON Schema generator module */ +@Deprecated public interface SchemaAware { /** diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/DefaultSerializerProvider.java b/src/main/java/com/fasterxml/jackson/databind/ser/DefaultSerializerProvider.java index cfef603728..9509933946 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/DefaultSerializerProvider.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/DefaultSerializerProvider.java @@ -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; @@ -583,8 +582,9 @@ public com.fasterxml.jackson.databind.jsonschema.JsonSchema generateJsonSchema(C * type information it needs is accessible via "untyped" serializer) */ JsonSerializer 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"); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java index 70caebfc24..c2f0bd8e66 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java @@ -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")); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/AsArraySerializerBase.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/AsArraySerializerBase.java index 759c44ff27..e074124711 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/AsArraySerializerBase.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/AsArraySerializerBase.java @@ -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; @@ -271,7 +270,10 @@ 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 @@ -279,8 +281,9 @@ public JsonNode getSchema(SerializerProvider provider, Type typeHint) 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(); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/BeanSerializerBase.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/BeanSerializerBase.java index bbd8d437ef..8df52f0797 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/BeanSerializerBase.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/BeanSerializerBase.java @@ -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.*; @@ -40,7 +38,7 @@ public abstract class BeanSerializerBase extends StdSerializer implements ContextualSerializer, ResolvableSerializer, - JsonFormatVisitable, SchemaAware + JsonFormatVisitable { protected final static PropertyName NAME_FOR_OBJECT_REF = new PropertyName("#object-ref"); @@ -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()) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/BooleanSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/BooleanSerializer.java index de691fb917..72bd899cc7 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/BooleanSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/BooleanSerializer.java @@ -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); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/ByteArraySerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/ByteArraySerializer.java index 69c2ae602f..07e196eca8 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/ByteArraySerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/ByteArraySerializer.java @@ -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) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/ClassSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/ClassSerializer.java index 6dfffcf80b..9ab21cc107 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/ClassSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/ClassSerializer.java @@ -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) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/DateTimeSerializerBase.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/DateTimeSerializerBase.java index 572d23eb62..73762eb8be 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/DateTimeSerializerBase.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/DateTimeSerializerBase.java @@ -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? diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java index 8fa003d156..933628ebfe 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java @@ -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) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/FileSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/FileSerializer.java index 696348aba7..9c7f28096b 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/FileSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/FileSerializer.java @@ -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); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/JsonValueSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/JsonValueSerializer.java index 9201cca43d..65854b1714 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/JsonValueSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/JsonValueSerializer.java @@ -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; @@ -41,7 +40,7 @@ @JacksonStdImpl public class JsonValueSerializer extends StdSerializer - implements ContextualSerializer, JsonFormatVisitable, SchemaAware + implements ContextualSerializer, JsonFormatVisitable { /** * @since 2.9 @@ -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(); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java index 36137c1e8b..36c3a3e8af 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java @@ -1102,6 +1102,10 @@ public void serializeFilteredAnyProperties(SerializerProvider provider, JsonGene /********************************************************** */ + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/NullSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/NullSerializer.java index e7e8a2f234..a21893fcf0 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/NullSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/NullSerializer.java @@ -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"); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializer.java index 86d49314d0..95acf710a7 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializer.java @@ -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); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializers.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializers.java index f9c2c6bd15..01ed61fcb3 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializers.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializers.java @@ -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); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/RawSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/RawSerializer.java index bed8e7a998..92d24ea002 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/RawSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/RawSerializer.java @@ -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) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlTimeSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlTimeSerializer.java index ba49c76b4f..3a3e2a419a 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlTimeSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlTimeSerializer.java @@ -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); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StaticListSerializerBase.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StaticListSerializerBase.java index 4f186b8ea7..9c8a717323 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StaticListSerializerBase.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StaticListSerializerBase.java @@ -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()); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdArraySerializers.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdArraySerializers.java index 93b646a46a..52f8dc215e 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdArraySerializers.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdArraySerializers.java @@ -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) { @@ -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) { @@ -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) { @@ -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")); @@ -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) { @@ -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")); @@ -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")); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java index 9973b85be2..727a62a9e1 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java @@ -5,7 +5,6 @@ import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable; 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.ser.ContextualSerializer; import com.fasterxml.jackson.databind.ser.ResolvableSerializer; @@ -29,7 +28,7 @@ public class StdDelegatingSerializer extends StdSerializer implements ContextualSerializer, ResolvableSerializer, - JsonFormatVisitable, SchemaAware + JsonFormatVisitable { protected final Converter _converter; @@ -201,22 +200,32 @@ public boolean isEmpty(SerializerProvider prov, Object value) /********************************************************** */ + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { - if (_delegateSerializer instanceof SchemaAware) { - return ((SchemaAware) _delegateSerializer).getSchema(provider, typeHint); + if (_delegateSerializer instanceof com.fasterxml.jackson.databind.jsonschema.SchemaAware) { + return ((com.fasterxml.jackson.databind.jsonschema.SchemaAware) _delegateSerializer) + .getSchema(provider, typeHint); } return super.getSchema(provider, typeHint); } + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint, boolean isOptional) throws JsonMappingException { - if (_delegateSerializer instanceof SchemaAware) { - return ((SchemaAware) _delegateSerializer).getSchema(provider, typeHint, isOptional); + if (_delegateSerializer instanceof com.fasterxml.jackson.databind.jsonschema.SchemaAware) { + return ((com.fasterxml.jackson.databind.jsonschema.SchemaAware) _delegateSerializer) + .getSchema(provider, typeHint, isOptional); } return super.getSchema(provider, typeHint); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdJdkSerializers.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdJdkSerializers.java index 7f7dc5870f..0599fda8f2 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdJdkSerializers.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdJdkSerializers.java @@ -66,7 +66,11 @@ public static class AtomicBooleanSerializer public void serialize(AtomicBoolean value, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.writeBoolean(value.get()); } - + + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("boolean", true); @@ -87,7 +91,11 @@ public static class AtomicIntegerSerializer public void serialize(AtomicInteger value, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.writeNumber(value.get()); } - + + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("integer", true); @@ -109,7 +117,11 @@ public static class AtomicLongSerializer public void serialize(AtomicLong value, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.writeNumber(value.get()); } - + + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("integer", true); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdScalarSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdScalarSerializer.java index 683a2f40f3..e1d9a84dd2 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdScalarSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdScalarSerializer.java @@ -58,6 +58,10 @@ public void serializeWithType(T value, JsonGenerator g, SerializerProvider provi typeSer.writeTypeSuffix(g, typeIdDef); } + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdSerializer.java index 3869d3319c..a1ca2fd0ad 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdSerializer.java @@ -15,7 +15,6 @@ import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.introspect.AnnotatedMember; import com.fasterxml.jackson.databind.jsonFormatVisitors.*; -import com.fasterxml.jackson.databind.jsonschema.SchemaAware; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.ser.FilterProvider; @@ -27,11 +26,11 @@ * Base class used by all standard serializers, and can also * be used for custom serializers (in fact, this is the recommended * base class to use). - * Provides convenience methods for implementing {@link SchemaAware} */ +@SuppressWarnings("deprecation") public abstract class StdSerializer extends JsonSerializer - implements JsonFormatVisitable, SchemaAware, java.io.Serializable + implements JsonFormatVisitable, com.fasterxml.jackson.databind.jsonschema.SchemaAware, java.io.Serializable { private static final long serialVersionUID = 1L; @@ -120,7 +119,11 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType t /** * Default implementation simply claims type is "string"; usually * overriden by custom serializers. + * + * @deprecated Since 2.15, we recommend use of external + * JSON Schema generator module */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { @@ -130,7 +133,11 @@ public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws Jso /** * Default implementation simply claims type is "string"; usually * overriden by custom serializers. + * + * @deprecated Since 2.15, we recommend use of external + * JSON Schema generator module */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint, boolean isOptional) throws JsonMappingException diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java index f9d525ac93..432a3772bd 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java @@ -49,6 +49,10 @@ public final void serializeWithType(Object value, JsonGenerator gen, SerializerP gen.writeString((String) value); } + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return createSchemaNode("string", true); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/ToEmptyObjectSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/ToEmptyObjectSerializer.java index ef4dbba9c1..bded43f0c2 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/ToEmptyObjectSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/ToEmptyObjectSerializer.java @@ -57,6 +57,10 @@ public boolean isEmpty(SerializerProvider provider, Object value) { return true; } + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase.java index 7e759f6d1c..034c2a3a9c 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase.java @@ -59,6 +59,10 @@ public void serializeWithType(Object value, JsonGenerator g, SerializerProvider typeSer.writeTypeSuffix(g, typeIdDef); } + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { return createSchemaNode("string", true); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/TokenBufferSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/TokenBufferSerializer.java index a7624b078e..8987d1cf9b 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/TokenBufferSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/TokenBufferSerializer.java @@ -56,6 +56,10 @@ public final void serializeWithType(TokenBuffer value, JsonGenerator g, typeSer.writeTypeSuffix(g, typeIdDef); } + /** + * @deprecated Since 2.15 + */ + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { diff --git a/src/test/java/com/fasterxml/jackson/databind/jsonschema/NewSchemaTest.java b/src/test/java/com/fasterxml/jackson/databind/jsonschema/NewSchemaTest.java index 8a42978fa9..75f6f6acf2 100644 --- a/src/test/java/com/fasterxml/jackson/databind/jsonschema/NewSchemaTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/jsonschema/NewSchemaTest.java @@ -148,7 +148,9 @@ private void _visit(BeanProperty prop) throws JsonMappingException } // and this just for bit of extra coverage... if (ser instanceof StdSerializer) { - assertNotNull(((StdSerializer) ser).getSchema(prov, prop.getType())); + @SuppressWarnings("deprecation") + JsonNode schemaNode = ((StdSerializer) ser).getSchema(prov, prop.getType()); + assertNotNull(schemaNode); } JsonFormatVisitorWrapper visitor = new JsonFormatVisitorWrapper.Base(getProvider()); ser.acceptJsonFormatVisitor(visitor, prop.getType()); diff --git a/src/test/java/com/fasterxml/jackson/databind/module/SimpleModuleTest.java b/src/test/java/com/fasterxml/jackson/databind/module/SimpleModuleTest.java index 6e824ea1ca..6352a96cf8 100644 --- a/src/test/java/com/fasterxml/jackson/databind/module/SimpleModuleTest.java +++ b/src/test/java/com/fasterxml/jackson/databind/module/SimpleModuleTest.java @@ -44,6 +44,7 @@ public void serialize(CustomBean value, JsonGenerator jgen, SerializerProvider p jgen.writeString(value.str + "|" + value.num); } + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return null; @@ -78,6 +79,7 @@ public void serialize(SimpleEnum value, JsonGenerator jgen, SerializerProvider p jgen.writeString(value.name().toLowerCase()); } + @Deprecated @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { return null;