Skip to content

Commit c4c490f

Browse files
authored
Merge pull request #617 from json-schema-org/gregsdennis/dynamicAnchor-inside-propertyDependencies
add tests for $dynamicAnchor in multiple branches of propertyDependencies
2 parents cf1b942 + d6490e8 commit c4c490f

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

tests/draft-next/dynamicRef.json

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,5 +484,94 @@
484484
"valid": true
485485
}
486486
]
487+
},
488+
{
489+
"description": "$dynamicAnchor inside propertyDependencies",
490+
"schema": {
491+
"$schema": "https://json-schema.org/draft/2020-12/schema",
492+
"$id": "http://localhost:1234/draft2020-12/dynamicanchor-in-propertydependencies.json",
493+
"$defs": {
494+
"inner": {
495+
"$id": "inner",
496+
"$dynamicAnchor": "foo",
497+
"type": "object",
498+
"additionalProperties": {
499+
"$dynamicRef": "#foo"
500+
}
501+
}
502+
},
503+
"propertyDependencies": {
504+
"expectedTypes": {
505+
"strings": {
506+
"$id": "east",
507+
"$ref": "inner",
508+
"$defs": {
509+
"foo": {
510+
"$dynamicAnchor": "foo",
511+
"type": "string"
512+
}
513+
}
514+
},
515+
"integers": {
516+
"$id": "west",
517+
"$ref": "inner",
518+
"$defs": {
519+
"foo": {
520+
"$dynamicAnchor": "foo",
521+
"type": "integer"
522+
}
523+
}
524+
}
525+
}
526+
}
527+
},
528+
"tests": [
529+
{
530+
"description": "expected strings - additional property as string is valid",
531+
"data": {
532+
"expectedTypes": "strings",
533+
"anotherProperty": "also a string"
534+
},
535+
"valid": true
536+
},
537+
{
538+
"description": "expected strings - additional property as not string is invalid",
539+
"data": {
540+
"expectedTypes": "strings",
541+
"anotherProperty": 42
542+
},
543+
"valid": false
544+
},
545+
{
546+
"description": "expected integers - additional property as integer is valid",
547+
"data": {
548+
"expectedTypes": "integers",
549+
"anotherProperty": 42
550+
},
551+
"valid": true
552+
},
553+
{
554+
"description": "expected integers - additional property as not integer is invalid",
555+
"data": {
556+
"expectedTypes": "integers",
557+
"anotherProperty": "a string"
558+
},
559+
"valid": false
560+
},
561+
{
562+
"description": "expected missing - additional property as an object is valid",
563+
"data": {
564+
"anotherProperty": {}
565+
},
566+
"valid": true
567+
},
568+
{
569+
"description": "expected missing - additional property as not object is invalid",
570+
"data": {
571+
"anotherProperty": 42
572+
},
573+
"valid": false
574+
}
575+
]
487576
}
488577
]

0 commit comments

Comments
 (0)