You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### To create a JsonSchemaFactory, automatically detecting schema version
52
63
53
64
```java
@@ -74,43 +85,45 @@ public enum VersionFlag {
74
85
V4(1<<0),
75
86
V6(1<<1),
76
87
V7(1<<2),
77
-
V201909(1<<3);
88
+
V201909(1<<3),
89
+
V202012(1<<4);
78
90
79
91
```
80
92
81
-
In the long value, we are using 4 bits now as we are supporting 4 versions at the moment.
93
+
In the long value, we are using 5 bits now as we are supporting 5 versions at the moment.
82
94
83
-
V4->0001->1
84
-
V6->0010->2
85
-
V7->0100->4
86
-
V201909->1000->8
95
+
V4->00001->1
96
+
V6->00010->2
97
+
V7->00100->4
98
+
V201909->01000->8
99
+
V202012->10000-->16
87
100
88
101
If we have a new version added, it should be
89
102
90
-
V202009 -> 10000 -> 16
103
+
V202209 -> 100000 -> 32
91
104
92
105
#### ValidatorTypeCode
93
106
94
107
A new field versionCode is added to indicate which version the validator is supported.
95
108
96
-
For most of the validators, the version code should be 15, which is 1111. This means the validator will be loaded for every version of the specification.
109
+
For most of the validators, the version code should be 31, which is 11111. This means the validator will be loaded for every version of the specification.
97
110
98
111
For example.
99
112
100
113
```
101
-
MAXIMUM("maximum", "1011", newMessageFormat("{0}: must have a maximum value of {1}"), MaximumValidator.class, 15),
114
+
MAXIMUM("maximum", "1011", newMessageFormat("{0}: must have a maximum value of {1}"), MaximumValidator.class, 31),
102
115
```
103
116
104
-
Sinceif-then-else was introduced in the V7, it only works forV7 and V2019-09
117
+
Sinceif-then-else was introduced in the V7, it only works forV7, V2019-09 and V2020-12
EXCLUSIVE_MAXIMUM("exclusiveMaximum", "1038", newMessageFormat("{0}: must have a exclusive maximum value of {1}"), ExclusiveMaximumValidator.class, 14), // V6|V7|V201909
126
+
EXCLUSIVE_MAXIMUM("exclusiveMaximum", "1038", newMessageFormat("{0}: must have a exclusive maximum value of {1}"), ExclusiveMaximumValidator.class, 30), // V6|V7|V201909|V202012
114
127
```
115
128
116
129
The getNonFormatKeywords method is updated to accept a SpecVersion.VersionFlag so that only the keywords supported by the specification will be loaded.
@@ -129,7 +142,7 @@ public static List<ValidatorTypeCode> getNonFormatKeywords(SpecVersion.VersionFl
129
142
130
143
#### JsonMetaSchema
131
144
132
-
We have created four different static classes V4, V6, V7, and V201909 to build different JsonMetaSchema instances.
145
+
We have created four different static classes V4, V6, V7, V201909and V202012 to build different JsonMetaSchema instances.
133
146
134
147
For the BUILDIN_FORMATS, there is a common section, and each staticclasshas its version-specific BUILDIN_FORMATS section.
135
148
@@ -144,21 +157,8 @@ public static JsonSchemaFactory getInstance() {
if (schemaUri.equals(JsonMetaSchema.getV4().getUri()))
182
185
return SpecVersion.VersionFlag.V4;
183
186
else if (schemaUri.equals(JsonMetaSchema.getV6().getUri()))
@@ -186,21 +189,24 @@ public static SpecVersion.VersionFlag detect(JsonNode jsonNode) {
186
189
return SpecVersion.VersionFlag.V7;
187
190
else if (schemaUri.equals(JsonMetaSchema.getV201909().getUri()))
188
191
return SpecVersion.VersionFlag.V201909;
192
+
else if (schemaUri.equals(JsonMetaSchema.getV202012().getUri()))
193
+
return SpecVersion.VersionFlag.V202012;
189
194
else
190
195
throw new JsonSchemaException("Unrecognizableschema");
191
196
}
192
197
```
193
198
194
199
### ForTesters
195
200
196
-
In the test resource folder, we have created and copied all draft version's test suite. They are located in draft4, draft6, draft7, and draft2019-09 folder.
201
+
In the test resource folder, we have created and copied all draft version's test suite. They are located in draft4, draft6, draft7, draft2019-09 and draft2020-12 folders.
197
202
198
203
The existing JsonSchemaTest has been renamed to V4JsonSchemaTest, and the following test classes are added.
199
204
200
205
```
201
206
V6JsonSchemaTest
202
207
V7JsonSchemaTest
203
208
V201909JsonSchemaTest
209
+
V202012JsonSchemaTest
204
210
```
205
211
206
212
These new test classes are not completed yet, and only some sample test cases are added.
0 commit comments