Skip to content

Commit f57d3e0

Browse files
authored
Merge pull request #631 from json-schema-org/if-then-else-ref
Ensure $ids are collected within if/then/else schemas.
2 parents 02905b2 + 3b8c281 commit f57d3e0

File tree

4 files changed

+264
-0
lines changed

4 files changed

+264
-0
lines changed

tests/draft-next/ref.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,5 +883,71 @@
883883
"valid": false
884884
}
885885
]
886+
},
887+
{
888+
"description": "ref to if",
889+
"schema": {
890+
"$ref": "http://example.com/ref/if",
891+
"if": {
892+
"$id": "http://example.com/ref/if",
893+
"type": "integer"
894+
}
895+
},
896+
"tests": [
897+
{
898+
"description": "a non-integer is invalid due to the $ref",
899+
"data": "foo",
900+
"valid": false
901+
},
902+
{
903+
"description": "an integer is valid",
904+
"data": 12,
905+
"valid": true
906+
}
907+
]
908+
},
909+
{
910+
"description": "ref to then",
911+
"schema": {
912+
"$ref": "http://example.com/ref/then",
913+
"then": {
914+
"$id": "http://example.com/ref/then",
915+
"type": "integer"
916+
}
917+
},
918+
"tests": [
919+
{
920+
"description": "a non-integer is invalid due to the $ref",
921+
"data": "foo",
922+
"valid": false
923+
},
924+
{
925+
"description": "an integer is valid",
926+
"data": 12,
927+
"valid": true
928+
}
929+
]
930+
},
931+
{
932+
"description": "ref to else",
933+
"schema": {
934+
"$ref": "http://example.com/ref/else",
935+
"else": {
936+
"$id": "http://example.com/ref/else",
937+
"type": "integer"
938+
}
939+
},
940+
"tests": [
941+
{
942+
"description": "a non-integer is invalid due to the $ref",
943+
"data": "foo",
944+
"valid": false
945+
},
946+
{
947+
"description": "an integer is valid",
948+
"data": 12,
949+
"valid": true
950+
}
951+
]
886952
}
887953
]

tests/draft2019-09/ref.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,5 +883,71 @@
883883
"valid": false
884884
}
885885
]
886+
},
887+
{
888+
"description": "ref to if",
889+
"schema": {
890+
"$ref": "http://example.com/ref/if",
891+
"if": {
892+
"$id": "http://example.com/ref/if",
893+
"type": "integer"
894+
}
895+
},
896+
"tests": [
897+
{
898+
"description": "a non-integer is invalid due to the $ref",
899+
"data": "foo",
900+
"valid": false
901+
},
902+
{
903+
"description": "an integer is valid",
904+
"data": 12,
905+
"valid": true
906+
}
907+
]
908+
},
909+
{
910+
"description": "ref to then",
911+
"schema": {
912+
"$ref": "http://example.com/ref/then",
913+
"then": {
914+
"$id": "http://example.com/ref/then",
915+
"type": "integer"
916+
}
917+
},
918+
"tests": [
919+
{
920+
"description": "a non-integer is invalid due to the $ref",
921+
"data": "foo",
922+
"valid": false
923+
},
924+
{
925+
"description": "an integer is valid",
926+
"data": 12,
927+
"valid": true
928+
}
929+
]
930+
},
931+
{
932+
"description": "ref to else",
933+
"schema": {
934+
"$ref": "http://example.com/ref/else",
935+
"else": {
936+
"$id": "http://example.com/ref/else",
937+
"type": "integer"
938+
}
939+
},
940+
"tests": [
941+
{
942+
"description": "a non-integer is invalid due to the $ref",
943+
"data": "foo",
944+
"valid": false
945+
},
946+
{
947+
"description": "an integer is valid",
948+
"data": 12,
949+
"valid": true
950+
}
951+
]
886952
}
887953
]

tests/draft2020-12/ref.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,5 +883,71 @@
883883
"valid": false
884884
}
885885
]
886+
},
887+
{
888+
"description": "ref to if",
889+
"schema": {
890+
"$ref": "http://example.com/ref/if",
891+
"if": {
892+
"$id": "http://example.com/ref/if",
893+
"type": "integer"
894+
}
895+
},
896+
"tests": [
897+
{
898+
"description": "a non-integer is invalid due to the $ref",
899+
"data": "foo",
900+
"valid": false
901+
},
902+
{
903+
"description": "an integer is valid",
904+
"data": 12,
905+
"valid": true
906+
}
907+
]
908+
},
909+
{
910+
"description": "ref to then",
911+
"schema": {
912+
"$ref": "http://example.com/ref/then",
913+
"then": {
914+
"$id": "http://example.com/ref/then",
915+
"type": "integer"
916+
}
917+
},
918+
"tests": [
919+
{
920+
"description": "a non-integer is invalid due to the $ref",
921+
"data": "foo",
922+
"valid": false
923+
},
924+
{
925+
"description": "an integer is valid",
926+
"data": 12,
927+
"valid": true
928+
}
929+
]
930+
},
931+
{
932+
"description": "ref to else",
933+
"schema": {
934+
"$ref": "http://example.com/ref/else",
935+
"else": {
936+
"$id": "http://example.com/ref/else",
937+
"type": "integer"
938+
}
939+
},
940+
"tests": [
941+
{
942+
"description": "a non-integer is invalid due to the $ref",
943+
"data": "foo",
944+
"valid": false
945+
},
946+
{
947+
"description": "an integer is valid",
948+
"data": 12,
949+
"valid": true
950+
}
951+
]
886952
}
887953
]

tests/draft7/ref.json

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,5 +818,71 @@
818818
"valid": false
819819
}
820820
]
821+
},
822+
{
823+
"description": "ref to if",
824+
"schema": {
825+
"$ref": "http://example.com/ref/if",
826+
"if": {
827+
"$id": "http://example.com/ref/if",
828+
"type": "integer"
829+
}
830+
},
831+
"tests": [
832+
{
833+
"description": "a non-integer is invalid due to the $ref",
834+
"data": "foo",
835+
"valid": false
836+
},
837+
{
838+
"description": "an integer is valid",
839+
"data": 12,
840+
"valid": true
841+
}
842+
]
843+
},
844+
{
845+
"description": "ref to then",
846+
"schema": {
847+
"$ref": "http://example.com/ref/then",
848+
"then": {
849+
"$id": "http://example.com/ref/then",
850+
"type": "integer"
851+
}
852+
},
853+
"tests": [
854+
{
855+
"description": "a non-integer is invalid due to the $ref",
856+
"data": "foo",
857+
"valid": false
858+
},
859+
{
860+
"description": "an integer is valid",
861+
"data": 12,
862+
"valid": true
863+
}
864+
]
865+
},
866+
{
867+
"description": "ref to else",
868+
"schema": {
869+
"$ref": "http://example.com/ref/else",
870+
"else": {
871+
"$id": "http://example.com/ref/else",
872+
"type": "integer"
873+
}
874+
},
875+
"tests": [
876+
{
877+
"description": "a non-integer is invalid due to the $ref",
878+
"data": "foo",
879+
"valid": false
880+
},
881+
{
882+
"description": "an integer is valid",
883+
"data": 12,
884+
"valid": true
885+
}
886+
]
821887
}
822888
]

0 commit comments

Comments
 (0)