File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
src/test/java/dev/harrel/jsonschema Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -242,6 +242,36 @@ void shouldFallbackToSchemaResolverWithFragment() {
242
242
);
243
243
}
244
244
245
+ @ Test
246
+ void shouldFallbackToSchemaResolverWithAnchor () {
247
+ Validator validator = new ValidatorFactory ()
248
+ .withDisabledSchemaValidation (true )
249
+ .withSchemaResolver (uri -> SchemaResolver .Result .fromString ("""
250
+ {
251
+ "$defs": {
252
+ "sub": {
253
+ "$anchor": "anchor",
254
+ "type": "string"
255
+ }
256
+ }
257
+ }""" ))
258
+ .createValidator ();
259
+
260
+ Validator .Result result = validator .validate (URI .create ("urn:test#anchor" ), "{}" );
261
+ assertThat (result .isValid ()).isFalse ();
262
+
263
+ List <Error > errors = result .getErrors ();
264
+ assertThat (errors ).hasSize (1 );
265
+ assertError (
266
+ errors .get (0 ),
267
+ "/$defs/sub/type" ,
268
+ "urn:test#/$defs/sub" ,
269
+ "" ,
270
+ "type" ,
271
+ "Value is [object] but should be [string]"
272
+ );
273
+ }
274
+
245
275
@ Test
246
276
void shouldFailResolvingExternalSchemaWithInvalidFragment () {
247
277
Validator validator = new ValidatorFactory ()
You can’t perform that action at this time.
0 commit comments