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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 13 additions & 10 deletions
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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 3 additions & 4 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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
{

0 commit comments

Comments
 (0)