1
1
package com .fasterxml .jackson .module .jsonSchema ;
2
2
3
- import com .fasterxml .jackson .annotation .JsonGetter ;
4
- import com .fasterxml .jackson .annotation .JsonIgnore ;
5
- import com .fasterxml .jackson .annotation .JsonInclude ;
6
- import com .fasterxml .jackson .annotation .JsonInclude .Include ;
7
- import com .fasterxml .jackson .annotation .JsonProperty ;
8
- import com .fasterxml .jackson .annotation .JsonSetter ;
9
- import com .fasterxml .jackson .annotation .JsonTypeInfo ;
3
+ import com .fasterxml .jackson .annotation .*;
10
4
import com .fasterxml .jackson .annotation .JsonTypeInfo .As ;
11
5
import com .fasterxml .jackson .annotation .JsonTypeInfo .Id ;
12
6
import com .fasterxml .jackson .databind .BeanProperty ;
13
- import com .fasterxml .jackson .databind .JavaType ;
14
7
import com .fasterxml .jackson .databind .annotation .JsonTypeIdResolver ;
15
8
import com .fasterxml .jackson .databind .jsonFormatVisitors .JsonFormatTypes ;
16
- import com .fasterxml .jackson .databind .jsontype .TypeIdResolver ;
17
- import com .fasterxml .jackson .databind .type .TypeFactory ;
18
- import com .fasterxml .jackson .module .jsonSchema .types .AnySchema ;
19
- import com .fasterxml .jackson .module .jsonSchema .types .ArraySchema ;
20
- import com .fasterxml .jackson .module .jsonSchema .types .BooleanSchema ;
21
- import com .fasterxml .jackson .module .jsonSchema .types .ContainerTypeSchema ;
22
- import com .fasterxml .jackson .module .jsonSchema .types .IntegerSchema ;
23
- import com .fasterxml .jackson .module .jsonSchema .types .NullSchema ;
24
- import com .fasterxml .jackson .module .jsonSchema .types .NumberSchema ;
25
- import com .fasterxml .jackson .module .jsonSchema .types .ObjectSchema ;
26
- import com .fasterxml .jackson .module .jsonSchema .types .SimpleTypeSchema ;
27
- import com .fasterxml .jackson .module .jsonSchema .types .StringSchema ;
28
- import com .fasterxml .jackson .module .jsonSchema .types .UnionTypeSchema ;
29
- import com .fasterxml .jackson .module .jsonSchema .types .ValueTypeSchema ;
9
+ import com .fasterxml .jackson .module .jsonSchema .types .*;
30
10
31
11
/**
32
12
* The type wraps the json schema specification at :
88
68
*
89
69
* @author jphelan
90
70
*/
91
- @ JsonInclude (Include .NON_EMPTY )
71
+ @ JsonInclude (JsonInclude . Include .NON_EMPTY )
92
72
@ JsonTypeInfo (use = Id .CUSTOM , include = As .PROPERTY , property = "type" )
93
- @ JsonTypeIdResolver (JsonSchema . JsonSchemaIdResolver .class )
73
+ @ JsonTypeIdResolver (JsonSchemaIdResolver .class )
94
74
public abstract class JsonSchema {
95
75
96
76
/**
@@ -146,8 +126,8 @@ public abstract class JsonSchema {
146
126
* "properties":{"deprecated":{"type": "boolean"}},
147
127
* "extends":"http://json-schema.org/draft-03/schema" }
148
128
*/
149
- @ JsonIgnore
150
129
private JsonSchema [] extendsextends ;
130
+
151
131
/**
152
132
* This attribute defines the current URI of this schema (this attribute is
153
133
* effectively a "self" link). This URI MAY be relative or absolute. If the
@@ -299,7 +279,6 @@ public JsonSchema[] getDisallow() {
299
279
return disallow ;
300
280
}
301
281
302
- @ JsonGetter ("extends" )
303
282
public JsonSchema [] getExtends () {
304
283
return extendsextends ;
305
284
}
@@ -449,7 +428,6 @@ public void setDisallow(JsonSchema[] disallow) {
449
428
this .disallow = disallow ;
450
429
}
451
430
452
- @ JsonSetter ("extends" )
453
431
public void setExtends (JsonSchema [] extendsextends ) {
454
432
this .extendsextends = extendsextends ;
455
433
}
@@ -497,69 +475,4 @@ public static JsonSchema minimalForFormat(JsonFormatTypes format) {
497
475
return new AnySchema ();
498
476
}
499
477
}
500
-
501
- public static class JsonSchemaIdResolver implements TypeIdResolver
502
- {
503
- /* This is Wrong: should not use defaultInstance() for anything.
504
- * But has to work for now...
505
- */
506
- private static JavaType any = TypeFactory .defaultInstance ().constructType (AnySchema .class );
507
- private static JavaType array = TypeFactory .defaultInstance ().constructType (ArraySchema .class );
508
- private static JavaType booleanboolean = TypeFactory .defaultInstance ().constructType (BooleanSchema .class );
509
- private static JavaType integer = TypeFactory .defaultInstance ().constructType (IntegerSchema .class );
510
- private static JavaType nullnull = TypeFactory .defaultInstance ().constructType (NullSchema .class );
511
- private static JavaType number = TypeFactory .defaultInstance ().constructType (NumberSchema .class );
512
- private static JavaType object = TypeFactory .defaultInstance ().constructType (ObjectSchema .class );
513
- private static JavaType string = TypeFactory .defaultInstance ().constructType (StringSchema .class );
514
-
515
- public JsonSchemaIdResolver () { }
516
-
517
- /* (non-Javadoc)
518
- * @see com.fasterxml.jackson.databind.jsontype.TypeIdResolver#idFromValue(java.lang.Object)
519
- */
520
- @ Override
521
- public String idFromValue (Object value ) {
522
- if ( value instanceof JsonSchema ) {
523
- return ((JsonSchema )value ).getType ().value ();
524
- }
525
- return null ;
526
- }
527
-
528
- /* (non-Javadoc)
529
- * @see com.fasterxml.jackson.databind.jsontype.TypeIdResolver#idFromValueAndType(java.lang.Object, java.lang.Class)
530
- */
531
- @ Override
532
- public String idFromValueAndType (Object value , Class <?> suggestedType ) {
533
- return idFromValue (value );
534
- }
535
-
536
- @ Override
537
- public JavaType typeFromId (String id ) {
538
- switch (JsonFormatTypes .forValue (id )) {
539
- case ANY : return any ;
540
- case ARRAY : return array ;
541
- case BOOLEAN : return booleanboolean ;
542
- case INTEGER : return integer ;
543
- case NULL : return nullnull ;
544
- case NUMBER : return number ;
545
- case OBJECT : return object ;
546
- case STRING : return string ;
547
- default :
548
- return null ;
549
- }
550
- }
551
-
552
- @ Override
553
- public Id getMechanism () {
554
- return Id .CUSTOM ;
555
- }
556
-
557
- @ Override
558
- public void init (JavaType baseType ) { }
559
-
560
- @ Override
561
- public String idFromBaseType () {
562
- return null ;
563
- }
564
- }
565
478
}
0 commit comments