1 package com.fasterxml.jackson.databind.jsonschema;
2 
3 import java.lang.annotation.RetentionPolicy;
4 import java.lang.annotation.Retention;
5 import java.lang.annotation.ElementType;
6 import java.lang.annotation.Target;
7 
8 import com.fasterxml.jackson.annotation.JacksonAnnotation;
9 
10 /**
11  * Annotation that can be used to define JSON Schema definition for
12  * the annotated class.
13  *<p>
14  * Note that annotation is often not needed: for example, regular
15  * Jackson beans that Jackson can introspect can be used without
16  * annotations, to produce JSON schema definition.
17  *
18  * @author Ryan Heaton
19  * @author Tatu Saloranta
20  */
21 @Target(ElementType.TYPE)
22 @Retention(RetentionPolicy.RUNTIME)
23 @JacksonAnnotation
24 public @interface JsonSerializableSchema
25 {
26     /**
27      * Marker value used to indicate that property has "no value";
28      * needed because annotations cannot have null as default
29      * value.
30      */
31     public final static String NO_VALUE = "##irrelevant";
32 
33     /**
34      * Property that can be used to indicate id of the type when
35      * generating JSON Schema; empty String indicates that no id
36      * is defined.
37      */
id()38     public String id() default "";
39 
40     /**
41      * The schema type for this JsonSerializable instance.
42      * Possible values: "string", "number", "boolean", "object", "array", "null", "any"
43      *
44      * @return The schema type for this JsonSerializable instance.
45      */
schemaType()46     public String schemaType() default "any";
47 
48     /**
49      * If the schema type is "object", JSON definition of properties of the object as
50      * a String.
51      *
52      * @return The node representing the schema properties, or "##irrelevant" if irrelevant.
53      *
54      * @deprecated (since 2.1) -- support will be dropped in future, since JSON-as-String is
55      *   fundamentally bad way for customizing anything. No direct replacements offered.
56      */
57     @Deprecated
schemaObjectPropertiesDefinition()58     public String schemaObjectPropertiesDefinition() default NO_VALUE;
59 
60     /**
61      * If the schema type if "array", JSON definition of the schema for item types contained.
62      *
63      * @return The schema for the items in the array, or "##irrelevant" if irrelevant.
64      *
65      * @deprecated (since 2.1) -- support will be dropped in future, since JSON-as-String is
66      *   fundamentally bad way for customizing anything. No direct replacements offered.
67      */
68     @Deprecated
schemaItemDefinition()69     public String schemaItemDefinition() default NO_VALUE;
70 }
71