Skip to content

Commit 5190ca4

Browse files
committed
deprecate classes in package jsonschema
1 parent abadc05 commit 5190ca4

33 files changed

+97
-48
lines changed

src/main/java/com/fasterxml/jackson/databind/ext/DOMSerializer.java

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public void serialize(Node value, JsonGenerator g, SerializerProvider provider)
5151
}
5252
}
5353

54+
@Deprecated
5455
@Override
5556
public JsonNode getSchema(SerializerProvider provider, java.lang.reflect.Type typeHint) {
5657
// Well... it is serialized as String

src/main/java/com/fasterxml/jackson/databind/jsonschema/JsonSerializableSchema.java

+13-10
Original file line numberDiff line numberDiff line change
@@ -10,61 +10,64 @@
1010
/**
1111
* Annotation that can be used to define JSON Schema definition for
1212
* the annotated class.
13-
*<p>
13+
* <p>
1414
* Note that annotation is often not needed: for example, regular
1515
* Jackson beans that Jackson can introspect can be used without
1616
* annotations, to produce JSON schema definition.
17-
*
17+
*
1818
* @author Ryan Heaton
1919
* @author Tatu Saloranta
20+
* @deprecated Since 2.2, we recommend use of external
21+
* <a href="https://github.com/FasterXML/jackson-module-jsonSchema">JSON Schema generator module</a>
2022
*/
2123
@Target(ElementType.TYPE)
2224
@Retention(RetentionPolicy.RUNTIME)
2325
@JacksonAnnotation
26+
@Deprecated
2427
public @interface JsonSerializableSchema
2528
{
2629
/**
2730
* Marker value used to indicate that property has "no value";
2831
* needed because annotations cannot have null as default
2932
* value.
3033
*/
31-
public final static String NO_VALUE = "##irrelevant";
34+
String NO_VALUE = "##irrelevant";
3235

3336
/**
3437
* Property that can be used to indicate id of the type when
3538
* generating JSON Schema; empty String indicates that no id
3639
* is defined.
3740
*/
38-
public String id() default "";
39-
41+
String id() default "";
42+
4043
/**
4144
* The schema type for this JsonSerializable instance.
4245
* Possible values: "string", "number", "boolean", "object", "array", "null", "any"
4346
*
4447
* @return The schema type for this JsonSerializable instance.
4548
*/
46-
public String schemaType() default "any";
49+
String schemaType() default "any";
4750

4851
/**
4952
* If the schema type is "object", JSON definition of properties of the object as
5053
* a String.
5154
*
5255
* @return The node representing the schema properties, or "##irrelevant" if irrelevant.
53-
*
56+
*
5457
* @deprecated (since 2.1) -- support will be dropped in future, since JSON-as-String is
5558
* fundamentally bad way for customizing anything. No direct replacements offered.
5659
*/
5760
@Deprecated
58-
public String schemaObjectPropertiesDefinition() default NO_VALUE;
61+
String schemaObjectPropertiesDefinition() default NO_VALUE;
5962

6063
/**
6164
* If the schema type if "array", JSON definition of the schema for item types contained.
6265
*
6366
* @return The schema for the items in the array, or "##irrelevant" if irrelevant.
64-
*
67+
*
6568
* @deprecated (since 2.1) -- support will be dropped in future, since JSON-as-String is
6669
* fundamentally bad way for customizing anything. No direct replacements offered.
6770
*/
6871
@Deprecated
69-
public String schemaItemDefinition() default NO_VALUE;
72+
String schemaItemDefinition() default NO_VALUE;
7073
}

src/main/java/com/fasterxml/jackson/databind/jsonschema/SchemaAware.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88

99
/**
1010
* Marker interface for schema-aware serializers.
11+
*
12+
* @deprecated Since 2.2, we recommend use of external
13+
* <a href="https://github.com/FasterXML/jackson-module-jsonSchema">JSON Schema generator module</a>
1114
*/
15+
@Deprecated
1216
public interface SchemaAware
1317
{
1418
/**
@@ -18,7 +22,7 @@ public interface SchemaAware
1822
* @param typeHint A hint about the type.
1923
* @return <a href="http://json-schema.org/">Json-schema</a> for this serializer.
2024
*/
21-
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
25+
JsonNode getSchema(SerializerProvider provider, Type typeHint)
2226
throws JsonMappingException;
2327

2428
/**
@@ -29,6 +33,6 @@ public JsonNode getSchema(SerializerProvider provider, Type typeHint)
2933
* @param typeHint A hint about the type.
3034
* @return <a href="http://json-schema.org/">Json-schema</a> for this serializer.
3135
*/
32-
public JsonNode getSchema(SerializerProvider provider, Type typeHint, boolean isOptional)
36+
JsonNode getSchema(SerializerProvider provider, Type typeHint, boolean isOptional)
3337
throws JsonMappingException;
3438
}

src/main/java/com/fasterxml/jackson/databind/ser/BeanPropertyWriter.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import com.fasterxml.jackson.databind.annotation.JacksonStdImpl;
1616
import com.fasterxml.jackson.databind.introspect.*;
1717
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor;
18-
import com.fasterxml.jackson.databind.jsonschema.SchemaAware;
1918
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
2019
import com.fasterxml.jackson.databind.node.ObjectNode;
2120
import com.fasterxml.jackson.databind.ser.impl.PropertySerializerMap;
@@ -874,9 +873,9 @@ public void depositSchemaProperty(ObjectNode propertiesNode,
874873
ser = provider.findValueSerializer(getType(), this);
875874
}
876875
boolean isOptional = !isRequired();
877-
if (ser instanceof SchemaAware) {
878-
schemaNode = ((SchemaAware) ser).getSchema(provider, hint,
879-
isOptional);
876+
if (ser instanceof com.fasterxml.jackson.databind.jsonschema.SchemaAware) {
877+
schemaNode = ((com.fasterxml.jackson.databind.jsonschema.SchemaAware) ser)
878+
.getSchema(provider, hint, isOptional);
880879
} else {
881880
schemaNode = com.fasterxml.jackson.databind.jsonschema.JsonSchema
882881
.getDefaultSchemaNode();

src/main/java/com/fasterxml/jackson/databind/ser/DefaultSerializerProvider.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.fasterxml.jackson.databind.introspect.Annotated;
1212
import com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition;
1313
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
14-
import com.fasterxml.jackson.databind.jsonschema.SchemaAware;
1514
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
1615
import com.fasterxml.jackson.databind.node.ObjectNode;
1716
import com.fasterxml.jackson.databind.ser.impl.WritableObjectId;
@@ -583,8 +582,9 @@ public com.fasterxml.jackson.databind.jsonschema.JsonSchema generateJsonSchema(C
583582
* type information it needs is accessible via "untyped" serializer)
584583
*/
585584
JsonSerializer<Object> ser = findValueSerializer(type, null);
586-
JsonNode schemaNode = (ser instanceof SchemaAware) ?
587-
((SchemaAware) ser).getSchema(this, null) : com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode();
585+
JsonNode schemaNode = (ser instanceof com.fasterxml.jackson.databind.jsonschema.SchemaAware)
586+
? ((com.fasterxml.jackson.databind.jsonschema.SchemaAware) ser).getSchema(this, null)
587+
: com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode();
588588
if (!(schemaNode instanceof ObjectNode)) {
589589
throw new IllegalArgumentException("Class " + type.getName()
590590
+" would not be serialized as a JSON object and therefore has no schema");

src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ private void serializeContentsSlow(String[] value, JsonGenerator gen, Serializer
210210
}
211211
}
212212

213+
@Deprecated
213214
@Override
214215
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
215216
return createSchemaNode("array", true).set("items", createSchemaNode("string"));

src/main/java/com/fasterxml/jackson/databind/ser/std/AsArraySerializerBase.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import com.fasterxml.jackson.databind.*;
1313
import com.fasterxml.jackson.databind.introspect.AnnotatedMember;
1414
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
15-
import com.fasterxml.jackson.databind.jsonschema.SchemaAware;
1615
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
1716
import com.fasterxml.jackson.databind.node.ObjectNode;
1817
import com.fasterxml.jackson.databind.ser.ContainerSerializer;
@@ -271,16 +270,17 @@ public void serializeWithType(T value, JsonGenerator g, SerializerProvider provi
271270
protected abstract void serializeContents(T value, JsonGenerator gen, SerializerProvider provider)
272271
throws IOException;
273272

274-
@SuppressWarnings("deprecation")
273+
@Deprecated
275274
@Override
276275
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
277276
throws JsonMappingException
278277
{
279278
ObjectNode o = createSchemaNode("array", true);
280279
if (_elementSerializer != null) {
281280
JsonNode schemaNode = null;
282-
if (_elementSerializer instanceof SchemaAware) {
283-
schemaNode = ((SchemaAware) _elementSerializer).getSchema(provider, null);
281+
if (_elementSerializer instanceof com.fasterxml.jackson.databind.jsonschema.SchemaAware) {
282+
schemaNode = ((com.fasterxml.jackson.databind.jsonschema.SchemaAware) _elementSerializer)
283+
.getSchema(provider, null);
284284
}
285285
if (schemaNode == null) {
286286
schemaNode = com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode();

src/main/java/com/fasterxml/jackson/databind/ser/std/BeanSerializerBase.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable;
1616
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
1717
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonObjectFormatVisitor;
18-
import com.fasterxml.jackson.databind.jsonschema.JsonSerializableSchema;
19-
import com.fasterxml.jackson.databind.jsonschema.SchemaAware;
2018
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
2119
import com.fasterxml.jackson.databind.node.ObjectNode;
2220
import com.fasterxml.jackson.databind.ser.*;
@@ -40,7 +38,7 @@
4038
public abstract class BeanSerializerBase
4139
extends StdSerializer<Object>
4240
implements ContextualSerializer, ResolvableSerializer,
43-
JsonFormatVisitable, SchemaAware
41+
JsonFormatVisitable
4442
{
4543
protected final static PropertyName NAME_FOR_OBJECT_REF = new PropertyName("#object-ref");
4644

@@ -849,7 +847,8 @@ public JsonNode getSchema(SerializerProvider provider, Type typeHint)
849847
ObjectNode o = createSchemaNode("object", true);
850848
// [JACKSON-813]: Add optional JSON Schema id attribute, if found
851849
// NOTE: not optimal, does NOT go through AnnotationIntrospector etc:
852-
JsonSerializableSchema ann = _handledType.getAnnotation(JsonSerializableSchema.class);
850+
com.fasterxml.jackson.databind.jsonschema.JsonSerializableSchema ann =
851+
_handledType.getAnnotation(com.fasterxml.jackson.databind.jsonschema.JsonSerializableSchema.class);
853852
if (ann != null) {
854853
String id = ann.id();
855854
if (id != null && !id.isEmpty()) {

src/main/java/com/fasterxml/jackson/databind/ser/std/BooleanSerializer.java

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public final void serializeWithType(Object value, JsonGenerator g, SerializerPro
7575
g.writeBoolean(Boolean.TRUE.equals(value));
7676
}
7777

78+
@Deprecated
7879
@Override
7980
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
8081
return createSchemaNode("boolean", !_forPrimitive);

src/main/java/com/fasterxml/jackson/databind/ser/std/ByteArraySerializer.java

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ public void serializeWithType(byte[] value, JsonGenerator g, SerializerProvider
6969
*/
7070
}
7171

72+
@Deprecated
7273
@Override
7374
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
7475
{

src/main/java/com/fasterxml/jackson/databind/ser/std/ClassSerializer.java

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public void serialize(Class<?> value, JsonGenerator g, SerializerProvider provid
2727
g.writeString(value.getName());
2828
}
2929

30+
@Deprecated
3031
@Override
3132
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
3233
{

src/main/java/com/fasterxml/jackson/databind/ser/std/DateTimeSerializerBase.java

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public boolean isEmpty(SerializerProvider serializers, T value) {
148148

149149
protected abstract long _timestamp(T value);
150150

151+
@Deprecated
151152
@Override
152153
public JsonNode getSchema(SerializerProvider serializers, Type typeHint) {
153154
//todo: (ryan) add a format for the date in the schema?

src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ public final void serialize(Enum<?> en, JsonGenerator gen, SerializerProvider se
139139
/**********************************************************
140140
*/
141141

142+
@Deprecated
142143
@Override
143144
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
144145
{

src/main/java/com/fasterxml/jackson/databind/ser/std/FileSerializer.java

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public void serialize(File value, JsonGenerator g, SerializerProvider provider)
2626
g.writeString(value.getAbsolutePath());
2727
}
2828

29+
@Deprecated
2930
@Override
3031
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
3132
return createSchemaNode("string", true);

src/main/java/com/fasterxml/jackson/databind/ser/std/JsonValueSerializer.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitable;
1818
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper;
1919
import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonStringFormatVisitor;
20-
import com.fasterxml.jackson.databind.jsonschema.SchemaAware;
2120
import com.fasterxml.jackson.databind.jsontype.TypeIdResolver;
2221
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
2322
import com.fasterxml.jackson.databind.ser.BeanSerializer;
@@ -41,7 +40,7 @@
4140
@JacksonStdImpl
4241
public class JsonValueSerializer
4342
extends StdSerializer<Object>
44-
implements ContextualSerializer, JsonFormatVisitable, SchemaAware
43+
implements ContextualSerializer, JsonFormatVisitable
4544
{
4645
/**
4746
* @since 2.9
@@ -302,13 +301,14 @@ public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider
302301
/**********************************************************
303302
*/
304303

305-
@SuppressWarnings("deprecation")
304+
@Deprecated
306305
@Override
307306
public JsonNode getSchema(SerializerProvider ctxt, Type typeHint)
308307
throws JsonMappingException
309308
{
310-
if (_valueSerializer instanceof SchemaAware) {
311-
return ((SchemaAware)_valueSerializer).getSchema(ctxt, null);
309+
if (_valueSerializer instanceof com.fasterxml.jackson.databind.jsonschema.SchemaAware) {
310+
return ((com.fasterxml.jackson.databind.jsonschema.SchemaAware) _valueSerializer)
311+
.getSchema(ctxt, null);
312312
}
313313
return com.fasterxml.jackson.databind.jsonschema.JsonSchema.getDefaultSchemaNode();
314314
}

src/main/java/com/fasterxml/jackson/databind/ser/std/MapSerializer.java

+1
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,7 @@ public void serializeFilteredAnyProperties(SerializerProvider provider, JsonGene
11021102
/**********************************************************
11031103
*/
11041104

1105+
@Deprecated
11051106
@Override
11061107
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
11071108
{

src/main/java/com/fasterxml/jackson/databind/ser/std/NullSerializer.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public void serializeWithType(Object value, JsonGenerator gen, SerializerProvide
4343
{
4444
gen.writeNull();
4545
}
46-
46+
47+
@Deprecated
4748
@Override
4849
public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException {
4950
return createSchemaNode("null");

src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializer.java

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public void serialize(Number value, JsonGenerator g, SerializerProvider provider
9191
}
9292
}
9393

94+
@Deprecated
9495
@Override
9596
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
9697
return createSchemaNode(_isInt ? "integer" : "number", true);

src/main/java/com/fasterxml/jackson/databind/ser/std/NumberSerializers.java

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ protected Base(Class<?> cls, JsonParser.NumberType numberType,
7575
|| (numberType == JsonParser.NumberType.BIG_INTEGER);
7676
}
7777

78+
@Deprecated
7879
@Override
7980
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
8081
return createSchemaNode(_schemaType, true);

src/main/java/com/fasterxml/jackson/databind/ser/std/RawSerializer.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public void serializeWithType(T value, JsonGenerator g, SerializerProvider provi
4141
serialize(value, g, provider);
4242
typeSer.writeTypeSuffix(g, typeIdDef);
4343
}
44-
44+
45+
@Deprecated
4546
@Override
4647
public JsonNode getSchema(SerializerProvider provider, Type typeHint)
4748
{

src/main/java/com/fasterxml/jackson/databind/ser/std/SqlTimeSerializer.java

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public void serialize(java.sql.Time value, JsonGenerator g, SerializerProvider p
2222
g.writeString(value.toString());
2323
}
2424

25+
@Deprecated
2526
@Override
2627
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
2728
return createSchemaNode("string", true);

src/main/java/com/fasterxml/jackson/databind/ser/std/StaticListSerializerBase.java

+1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public boolean isEmpty(SerializerProvider provider, T value) {
106106
return (value == null) || (value.isEmpty());
107107
}
108108

109+
@Deprecated
109110
@Override
110111
public JsonNode getSchema(SerializerProvider provider, Type typeHint) {
111112
return createSchemaNode("array", true).set("items", contentSchema());

0 commit comments

Comments
 (0)